Skip to content
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

Schema optimisations and consistency of indexes between Django and SqlAlchemy #2303

Closed
2 tasks
giovannipizzi opened this issue Dec 6, 2018 · 0 comments · Fixed by #5097
Closed
2 tasks
Assignees
Labels
topic/database-schema type/performance Issue related to how quickly AiiDA works

Comments

@giovannipizzi
Copy link
Member

There are (still) important differences between the schema generated by SQLA and Django.
To make sure they are the same, we SHOULD NOT check only the python code, but actually the information in the DB schema, asking psql.
For instance, while Django correctly adds two indices for type:

=> select * from pg_indexes where tablename='db_dbnode' and indexdef LIKE '%type%';
 schemaname | tablename |              indexname               | tablespace |                                                   indexdef                                                   
------------+-----------+--------------------------------------+------------+--------------------------------------------------------------------------------------------------------------
 public     | db_dbnode | db_dbnode_599dcce2                   |            | CREATE INDEX db_dbnode_599dcce2 ON public.db_dbnode USING btree (type)
 public     | db_dbnode | db_dbnode_type_4cda33f938ccd765_like |            | CREATE INDEX db_dbnode_type_4cda33f938ccd765_like ON public.db_dbnode USING btree (type varchar_pattern_ops)
(2 rows)

SQLA does not generate the second index (varchar_pattern_ops) that is essential for making queries for "startwith" in a string (LIKE 'xxx%') that are used a lot in queries on the type. See also Postgres docs.

Tasks:

  • Make sure all relevant char fields have also a varchar_pattern_ops
  • Make a test that checks the schema autogenerated by Django as SQLA and compares it with some reference data to check if indexes and similar are the same (same uniqueness, same indexes and index types, ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/database-schema type/performance Issue related to how quickly AiiDA works
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants