On Monday, October 12, 2015 2:52 PM, Lele Gaifax <lele@xxxxxxxxxxxxxxx> wrote: > I'm doing some experiments to find the better layout for > reimplementing an existing db (MySQL cough!) with PostgreSQL > 9.4+. > > I noticed a strange plan coming out from a simple query joining > two tables, both containing 10Mrecs (and both ANALYZEd): Your best bet to get good advice on this is to follow the steps outlined here: https://wiki.postgresql.org/wiki/SlowQueryQuestions The short answer to the question of why it is picking those plans is that that the optimizer looks at the various plans that can generate correct results, and picks the one with the lowest estimated cost based on your costing factors. To get a plan more like what you seem to be expecting you might need to adjust cost factors or create an index that allows more direct access to the data needed by the query. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general