> I have simplified the query and added the last advise that you told me:
>
> Query:
>
> explain analyze select * from (select * from entity_compounddict2document where name='ranitidine') as a order by a.hepval;
>
Do you need full result?
If you need just top-n rows, then index on entity_compounddict2document(name, a.hepval) might help.
Regards,
Vladimir Sitnikov