2017-09-12 12:39 GMT+02:00 Pavel Stehule <pavel.stehule@xxxxxxxxx>:
>
> from statistics - the ar_tran_inv table is scanned 6x in slow query
and 2times in fast query. Maybe there should be some index
>
Setting enable_nestloop to off makes no difference.
Setting from_collapse_limit and join_collapse_limit to 16, as suggested by
Tom, actually slowed it down. I mentioned before that I was running this from python, which complicated
it slightly. I have now saved the command to a file on the Fedora side, so I can
execute it in psql using the ‘\i’ command. It makes life easier, and I can use
‘\timing’ to time it. It shows exactly the same results.
It could be an index problem, but I have just double-checked that, if I
remove the lines from the body of the statement that actually select from the
joined tables, it makes virtually no difference. However, maybe the planner
checks to see what indexes it has before preparing the query, so that does not
rule it out as a possibility.
I will play with it some more tomorrow, when my brain is a bit
fresher. I will report back with any results.
Frank
|