jjb_official's avatar

Postgres index deleted_at column

Hello, the following query takes approximately 1.2 seconds to run even though the total number of rows is only 10

SELECT * FROM "users" WHERE "id" = 1 AND "users"."deleted_at" IS NULL LIMIT 1 I have tried adding creating an index on the users table using the following SQL

CREATE INDEX idx_del ON users(id,deleted_at);

However, when I run the query again using explain, I still get a sequential scan instead of an index scan. Does anyone know why Postgres is not using the index?

0 likes
0 replies

Please or to participate in this conversation.