Hi All,
I am new to PostgreSQL. I have a query that needs to be optimized.
select c.id,c.trust, c.account_no, cd.firstname, cd.lastname,cd.street1, cd.city, cd.state, cd.country,cd.postal, cd.phone from customer c inner join customerdata cd on c.id = cd.uid where (lower(login)=lower('') OR lower(email) = lower(''));
The id field in customer is a primary key, and I added an index on uid field in customerdata. uid field in customerdata is a FK on id field in customer.
The current run-time of the query is 93.35 msec. The query does not do an index scan as it uses OR in the where clause.
I broke the query into two queries(each with one of the OR condns) and checked the time. Though it gives better performance (combined runtime of 47.1 msec), it still does not do index scan on both tables.
Can anyone tell me how to change the query to optimize the run-time?
Thanks a lot!