0

In our web-applicatons we have PostgreSQL database. Users write into and delete from this database ecology forecasts. Because data amount is significant (more than 100 Gb), we use declarative partitioning for largest tables. Tables partitioned by forecast identifier. Partition creating and dropping is made "on the fly" when users create or delete forecasts. However, I doubt if creating partitions in this way is good idea.

EDITED. We do not use creating partition by BEFORE INSERT trigger. We create or drop section on backend after user start creating or deleting forecast on frontend of our web-application.

EDITED 2. Backend in our web-application is web-server, that works with PostgreSQL 12 database.

1 Answer 1

0

Usually it is the best thing to create partitions for the data you expect ahead of time and handle the error when unexpected data arrive.

There is also the option of a default partition that receives data that belongs into no other partition, but that is usually only a good idea if you have a fixed number of partitions, because conflicting data in the default partition prevents creation of a new partition.

3
  • We do not use creating partition by BEFORE INSERT trigger. We create or drop section on backend after user start creating or deleting forecast on frontend of our web-application. Commented Sep 17, 2020 at 12:55
  • With "backend" you probably mean the application. Does the application know which partitions exist or does it have to query the database for every row that it wants to insert? The latter would probably not make for good performance, the former (caching that information) poses the problem tat the cache might get stale. Perhaps catching an error, creating the partition if necessary and retrying is the most performant option. Commented Sep 17, 2020 at 13:34
  • Application knows that new partition do not exist before creating and partition for deleting exists before deleting. Commented Sep 17, 2020 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.