Ron Johnson <ronljohnsonjr@xxxxxxxxx> writes: > Since the query works in PgAdmin, but not in npgsql, the problem has to be > somewhere in Npgsql. I'm wondering if npgsql is executing the query as a cursor and that is causing the planner to make a poor choice of plan. There is a bias towards fast-start plans if you use a cursor, and that doesn't always work well :-( regards, tom lane