-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use plain "create table as" if possible #251
base: master
Are you sure you want to change the base?
Conversation
We need to split the copying of data into the new table into separate commands if we need any per-column storage settings. In this case we must use this order: - create table as .. with no data; - alter table .. alter column .. - insert into .. select But this is pointless if we don't need to change the column. At the same time, a single "create table as" command may be very useful for performing --order-by because it may use parallel query execution feature in PostgreSQL. INSERT .. SELECT currently cannot use parallel plans.
This is interesting, but I wonder what is the locking behaviour? If a CREATE TABLE AS takes a long time, is the system catalog locked? Can you run concurrent DDL instructions concurrently? |
There is no such global system catalog locking in postgresql.
On other objects - yes. You will wait transaction with another Also transaction locks released only at commit (or rollback). LWLock should not holding in long time (otherwise it's postgresql bug). So here is no actual difference in behaviour, currently |
In non-parallel cases, this seems like it might cause repack to be slower, but the locking mechanics are no worse, so it should be just as safe as the current repack. |
hm, why? |
You'll have to sort the data before it can be inserted; the larger the table, the more expensive / time consuming that process will be. I don't see it as a show stopper, but something people may want to think about (especially as I don't see a lot of systems being well tuned for parallel work). |
Right. But there is no performance regression:
|
@Melkij Any way you can test the correct creation of the table, with all options and also include the order by? |
@Melkij would you update the patch? |
Use CREATE TABLE as SELECT allowing parallel plans if it is possible.
Hello
We need to split the copying of data into the new table into separate commands if we need any per-column storage settings.
In this case we must use this order:
But this is pointless if we don't need to change the column.
At the same time, a single "create table as" command may be very useful for performing
--order-by
because it may use parallel query execution feature in PostgreSQL. INSERT .. SELECT currently cannot use parallel plans.