Comment

Comment by FreeHugs

    Try to avoid the use of ‘IN’ or ‘NOT IN’. By
    doing this you are performing a full table scan
    as the query engine looks through every row to
    check if the condition is met.
Is that really true for PostgreSQL? Take this query for example:

   SELECT * FROM t WHERE id IN (1,2,3)
I do this often in MySql DBs. I am pretty sure it uses an index on "id" if one exists. EXPLAIN confirms this. Why would a DB engine not use an index?
parent FreeHugs 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton