- select * from documents where profile_id = ? (multiple rows returned, doing a full scan) --- 5 sec
See https://phoenix.apache.org/secondary_indexing.html#Index_Usage for when an index is used/not used, but by default a global index won't be used if not all columns are contained in the index (i.e. covered index).
- select profile_id from documents_test order by added desc limit 1 (index on added) --- 5.5 sec
If PROFILE_ID is not in the primary key constraint of the table, make sure to include it in your index on the ADDED column.
Elsevier Limited. Registered Office: The Boulevard, Langford Lane, Kidlington, Oxford, OX5 1GB, United Kingdom, Registration No. 1982084, Registered in England and Wales.