> I'm quite happy with the speedup in 3, but puzzled over the slowdown in
> 2.
Could you provide :
- SELECT count(*) FROM structure;
=> NRows
- SELECT avg(length(smiles)) FROM structure;
Then VACUUM FULL ANALYZE structure
Redo your timings and this time post EXPLAIN ANALYZE
Also your query returns 1313 rows, so wan you post :
EXPLAIN ANALYZE SELECT oe_matches(smiles,'c1ccccc1CC(=O)NC') FROM
structure;
=> time T1
EXPLAIN ANALYZE SELECT smiles FROM structure;
=> time T2
(T1-T2)/(NRows) will give you an estimate of the time spent in each
oe_matches call.
Also note that for postgres (a,b) > (c,d) means ((a>c) and (b>d)), which
can be misleading, but I think that's what you wanted.