low cardinality attribute should be included in Index?

0
We are investigating which attributes should be given an index and in what order in order to improve performance. I have two questions. 1. Should I include attributes which are low cardinality as an index? 2. If so, should these item be at the end of the INDEX? I would like to know if there are any Mendix-specific perspectives other than general SQL tuning. (postgres)   Thank you in advance.
asked
1 answers
0

As the runtime translates the xpath statements into SQL statements the rules for SQL tuning still apply here. So adding an index on a low cardinality attribute would help if one of the values is very infrequent compared to the other possible values.

If the distribution of the possible values is similar for all possible values then the postgres database will read the table as it is aware of the values via the statistics of the table.

Small tables could benefit from an index, but the database could also perform a bitmap scan.

If you want to know what the database will do in a specific instance then get the specific query from the logs by setting the lognode for this to trace level and perform the query from pgadmin.

This will tell you how to write your xpath statement for optimal performance, with the most discriminating select at the beginning of the statement. 
For some details on the order of the columns in the index have a look at: https://www.postgresql.org/docs/current/indexes-multicolumn.html

answered