Jagmohan Kaintura <jagmohan@xxxxxxxxxxxxxx> writes: > When we are compiling View definition into database , the where clause on > the Character Columns is getting internally typecasted to text. That's normal. In Postgres, varchar has no operators of its own; everything you might do with it involves a (no-cost) cast to text. You might think of varchar as being a domain over text, though for historical reasons it's not implemented exactly that way. > These Columns are Primary Key columns and because of this Type Casting on > those columns Index scan is not happening and we are always getting > Sequential Scan. This, on the other hand, is just nonsense. You haven't presented any examples in which an indexscan looks likely to be a win. Postgres generally won't bother with an index when scanning a tiny table. Nor is an index necessarily helpful when doing a join, unless the join is designed to access just a small part of the table. > Please help us in identifying the solution. Please read https://wiki.postgresql.org/wiki/Slow_Query_Questions regards, tom lane