Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Don't overthink that part. Just rely on EXPLAIN. It will tell you if the query had an index to use or if it scanned. You'd be surprised when a DB does/doesn't use an index if you try to figure it out yourself.

A run book for any org when writing queries should be

1) Write the query

2) Before shipping the query run the query through EXPLAIN. Did it scan or did it use an index?

3) If it scanned can you re-write it to use an existing index (the usual answer honestly).

4) Create the index.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: