Search code examples
node.jsdatabaseamazon-qldbpartiql

Will this SELECT QLDB query using index be optimized or not


I have one table with some indexes and some different columns. I am running this query to get the result of a user's data, not all the user data.

The user field is defined by UID The time field is defined by TimeValue (i am entering time in numbers so I can compare them) Data that I want is defined by Cause column

This is my query. Will this query do a table scan or will it only search for those rows where UID is the given one.

UID, TimeValue and Cause are index as well

SELECT Cause, Cause_Amount, UID FROM Contribution WHERE UID = 'u5JvslEo9DbQ7hcq4vkM74dWlxr2' AND TimeValue > 1620414948000 AND ( Cause = 'cleanAir' OR Cause = 'safeWater')


Solution

  • One way to check to see what QLDB is doing is to look at the ReadIOs value that comes back in your query stats. If you are seeing that your ReadIOs matches the total number of documents in the table, it is likely doing a scan, if it's lower, then you are using the index.