One thing that most people don't have to worry about in MySQL is case-sensitivity. Unless you're trying to authenticate a user against a database password and don't use MD5 (like you should!), in which case the password is not case sensitive by default.
In PostgreSQL everything is case sensitive. That means that if you have a user "Bob", and you run a query such as:
SELECT * FROM users WHERE username = 'bob';
you won't get a match. You can get around that by using:
SELECT * FROM users WHERE LOWER(username) = LOWER('bob');
However, now PostgreSQL will ignore your regular index on the username column. Fortunately, PostgreSQL will let you create indexes based on expressions. In this case you'd want to use the following index:
CREATE UNIQUE INDEX myindex ON users((LOWER(username));
Cheers!




Discussion
No comments for “Indexes in PostgreSQL”