I have a public copy of the Stack Overflow database here on AWS Aurora Postgres 15.5:
- Server: query.smartpostgres.com
- Username: readonly
- Password: 511e0479-4d35-49ab-98b1-c3a9d69796f4
The users table has this index:
create index users_length_displayname on users(length(displayname));
But when I run either of these queries:
select * from users where length(displayname) > 35;
select length(displayname) from users where length(displayname) > 35;
They don't use the functional index, as evidenced by their query plans:
So, uh, why?