<div dir="ltr"><div>Hi, Thanks Nyall for the hints. <br></div><div><br></div><div>I'm considering switching to this query instead.<br></div><div>SELECT * FROM pg_class WHERE relname='qgis_editor_widget_styles'</div><div><br></div><div>In my setup it access only to one table and uses internal indexes, 
when the information_schema.tables is a view that involve a materialized
 query here when using explain. <br></div><div>I don't see a significant difference on my local setup, I'll test it on our customer setup before starting my (first) PR!</div><div><br></div><div>Cheers</div><div>Régis<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le sam. 25 mai 2019 à 05:33, Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, 24 May 2019 at 18:25, Régis Haubourg <<a href="mailto:regis.haubourg@gmail.com" target="_blank">regis.haubourg@gmail.com</a>> wrote:<br>
><br>
> Hi all,<br>
> I'm facing very slow opening of project files for a customer here in QGIS 3.4.5. Something like 7 minutes, against 30 s in QGIS 2.18.<br>
><br>
> We are still investigating to narrow it down, but I faced a first query in the logs that I fail to understand.<br>
><br>
> QGIS emits this at a point:<br>
<br>
><br>
> And this query is long in our context, 1.7s, because of a very high number of tables and schemas in that production DB.<br>
><br>
> I found at [0] in the postgres provider where it comes from, I found the associated PR [1], but I fail to understand in what workflow this table is created using QGIS, and what it is used for.<br>
><br>
> Can someone put some light here ?<br>
<br>
There's a unit test at<br>
<br>
<a href="https://github.com/qgis/QGIS/pull/3439/files#diff-99b101819133a316786604243f3abf6eR318" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/pull/3439/files#diff-99b101819133a316786604243f3abf6eR318</a><br>
<br>
and<br>
<br>
<a href="https://github.com/qgis/QGIS/pull/3439/files#diff-03e6d7f6f76fb4bcab508984d0fd05f6R443" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/pull/3439/files#diff-03e6d7f6f76fb4bcab508984d0fd05f6R443</a><br>
<br>
which partially explains this -- it looks like it's a way to specify a<br>
default editor widget configuration for a table, which is used<br>
whenever that table is loaded into QGIS.<br>
<br>
><br>
> select count(*)<br>
><br>
> from information_schema.tables<br>
><br>
> where table_name = 'qgis_editor_widget_styles' ;<br>
><br>
<br>
Looks like that query could be substantially improved -- it's only<br>
testing for existence of the table, so calculating the count is<br>
inefficient and requiring a whole table scan.<br>
<br>
Nyall<br>
</blockquote></div>