maxtepkeev / architect

A set of tools which enhances ORMs written in Python with more features
Other
391 stars 57 forks source link

Best way to partition by list name? #48

Closed aztrock closed 3 years ago

aztrock commented 6 years ago

How would be the best way to make a partition by example name:

White_list blacklist general_list list_first_income # @

maxtepkeev commented 6 years ago

Hi,

This is called list partitioning, i.e. when you have a list of choices to choose from. Unfortunately it isn't supported by Architect yet, but if you're using PostgreSQL you can overcome this limitation by using string_firstchars range partitioning.

You need to have a column that will contain a type of the list, for example list_type and the values can be white, black, general, first_income and so on and this is the column you should partition your table with using string_firstchars as type and put some big number inside the constraint option, e.g. 20, otherwise if you put a number like 5, you will end up with partition first for the list type first_income, gener for general and so on, so you need a number which is equal or bigger than your longest list type name.

maxtepkeev commented 3 years ago

I believe this can be closed.