Re: Table partitioning
От | Steve Crawford |
---|---|
Тема | Re: Table partitioning |
Дата | |
Msg-id | 526EC9A5.9090906@pinpointresearch.com обсуждение исходный текст |
Ответ на | Table partitioning (Herouth Maoz <herouth@unicell.co.il>) |
Список | pgsql-general |
On 10/28/2013 09:27 AM, Herouth Maoz wrote: > I have a rather large and slow table in Postgresql 9.1. I'm thinking of partitioning it by months, but I don't like theidea of creating and dropping tables all the time. What is slow about it? Inserting? Selecting? Deleting? Partitioning can assist with some issues but does no good if what you really need is an index or better query. Partitioning shines as an option to manage archiving/purging of time-series data but only if you work with it, not against it. What don't you like about creating and dropping tables? You can easily automate it: https://github.com/keithf4/pg_partman > > I'm thinking of simply creating 12 child tables, in which the check condition will be, for example, date_part('month'',time_arrived) = 1 (or 2 for February, 3 for March etc.). > > I'll just be deleting records rather than dropping tables, the same way I do in my current setup. I delete a week's worthevery time. You are missing out on one of the best aspects of partitioning. Compared to dropping or truncating a child table, deleting is far slower and causes table bloat which may impact future queries. > > Second, when I delete (not drop!) from the mother table, are records deleted automatically from the child tables or doI need to create rules/triggers for that? > Yes unless you use the keyword "ONLY": "If specified, deletes rows from the named table only. When not specified, any tables inheriting from the named table are also processed." Cheers, Steve
В списке pgsql-general по дате отправления: