-
Notifications
You must be signed in to change notification settings - Fork 55
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
How to SELECT from partitions with ORM? #34
Comments
With table partitioning you just select from the master table as you do without partitioning, database takes care about which partition to query for you. That's the whole point of partitioning. You don't need to know which partition to query for a specific record. |
So when query like this: And when |
No, it's more complicated than that and it depends on how Django constructs underlying query. This is a big topic, if you want to know low-level details please have a look at the PostgreSQL docs for partitioning. Also you're using the foreign key for partitioning, that is a bad idea with PostgreSQL, see #27 (comment) for details. |
thanks if interesting, "explain" for
scan tables: app_searchresult, app_searchresult_1_100 and app_searchresult_3501_3600 Query without "Where":
Scan all created tables in this partitioning |
I have a Django model like this:
When I am selecting with ORM filtering by partition column
SearchResult.objects.filter(search_id=3502).only('id').first()
Django selects from master table:
How I can select something with ORM from tables caled like "app_searchresult_3501_3600"?
I believe that I don't need to know a table name for this.
The text was updated successfully, but these errors were encountered: