In article <b80d582c0603212153p654d0f06t4ddfec76ada2bfce@xxxxxxxxxxxxxx>, Luckys <plpgsql@xxxxxxxxx> writes: > I believe you should restrict number of rows that needs to be returned, or > giving a choice to the user, although showing the total count. Even if you > display all 20K records, no one is going to see them all, you can even add > one more LIKE condition to match the user's criteria. I second that. Whenever you connect an interactive application to a DB backend and you don't know in advance some upper limit for the number of rows returned by a query, append a "LIMIT 1000" or something like that.