bombadil(at)wanadoo(dot)es writes:
> Here are my queries:
You sure you didn't paste in the same result for #2 and #3? They're
the same plan with the same rows estimates --- but I'd expect the rows
estimates, at least, to change given the more-selective LIKE pattern.
Also, how many rows are there really that match '%DA%' and '%DAVID%'?
I suspect the planner is being overoptimistic about the selectivity of
'%DAVID%', and is choosing a plan that doesn't work well when there are
lots of DAVIDs :-(
regards, tom lane