2017-04-21 9:05 GMT+02:00 Marco Renzi <renzi.mrc@xxxxxxxxx>:
I am thinking so limit 10000 should be ok. Too big number can be messy for optimizer similarly like too small number.The planner is driven by statistics - and the statistics are not perfect - usually it is working on 80% - like weather forecasting.Usually it is working, but sometimes not.RegardsPavel
Thanks for the helpThanks Pavel, i almost found two solutions at the end:One is to use an inner limit as you said, and the other, when you just know what the filter is,
is to try to join with SELECTS that have to be executed first from the planner.
Eg
SELECT fase.id
FROM tipofase
JOIN fase
ON (fase.tipofase = (SELECT tipofase.id FROM tipofase WHERE tipofase.agendafrontoffice = true))
ORDER BY fase.id DESC limit 10 offset 0
yes, sometimes when the data are not homogeneous more queries are necessary
Regards
Pavel
--------------------------------"The fastest way to change yourself is to hang out with people who are already the way you want to be" Reid Hoffman------------------------------ ------------------------------ ------------------------------ -------------------
Ing. Marco Renzi
OCA - Oracle Certified Associate Java SE7 Programmer
OCP - Oracle Certified Mysql 5 Developer
via Zegalara 57
62014 Corridonia(MC)
Mob: 3208377271