Searches on layers with many attributes are slow despite having indexes on the attributes I want to search. How can I speed this up? The 2019 Stack Overflow Developer Survey Results Are InSearching feature in QGIS?Full Text Search in ArcSDEQGIS 2.10.1 & SQL Server 2014How to refresh or update a vrt layer in Qgis?Cannot activate the Feature Search in ArcGIS Online?Should the QGIS “DB Manager” have Microsoft SQL Server as an option?Search MXDs with specific dataSource layer using PythonLimit ST_DWithin() to first candidate foundMS SQL Layer - Losing LineStrings (Polyline) from SQL Server to QGISHow to configure the search in a qgis2web map?Search feature property in a leaflet layerGroup not producing a result

How much of the clove should I use when using big garlic heads?

When should I buy a clipper card after flying to Oakland?

Can withdrawing asylum be illegal?

Is "plugging out" electronic devices an American expression?

How to translate "being like"?

What is the meaning of Triage in Cybersec world?

Is patent abuse being used to block high-lumen headlamps that run on standard batteries?

A word that means fill it to the required quantity

How can I define good in a religion that claims no moral authority?

Portfast on Trunk port

Why are there uneven bright areas in this photo of black hole?

Pokemon Turn Based battle (Python)

Why is ParallelDo slower than Do?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Can an undergraduate be advised by a professor who is very far away?

Worn-tile Scrabble

Why doesn't shell automatically fix "useless use of cat"?

Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past

Merge two greps into single one

Can we generate random numbers using irrational numbers like π and e?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Sums of normal random variables

Why does the nucleus not repel itself?

"as much details as you can remember"



Searches on layers with many attributes are slow despite having indexes on the attributes I want to search. How can I speed this up?



The 2019 Stack Overflow Developer Survey Results Are InSearching feature in QGIS?Full Text Search in ArcSDEQGIS 2.10.1 & SQL Server 2014How to refresh or update a vrt layer in Qgis?Cannot activate the Feature Search in ArcGIS Online?Should the QGIS “DB Manager” have Microsoft SQL Server as an option?Search MXDs with specific dataSource layer using PythonLimit ST_DWithin() to first candidate foundMS SQL Layer - Losing LineStrings (Polyline) from SQL Server to QGISHow to configure the search in a qgis2web map?Search feature property in a leaflet layerGroup not producing a result



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I'm using QGIS 3 with my data in a PostGIS server on the same local network. I want to quickly search for a feature based on a certain attribute or attributes of my layer. I've tried a couple methods, but keep running into performance much slower than it could be.



When I use the locator bar per this answer, I see some results quickly when I start typing the value, but when I type more it stops showing results, and I have to wait ±30 seconds before it finally finds the match.



When I use the Search Layers plugin, I get the match(es) practically immediately if I specify both the layer and the attribute. If it's set to "<All Layers>", or "<All Fields>", it takes a long time to return anything. However, if I close the plugin window and open it later, it defaults back to "<All Layers>".



This layer has ±2 million features, and 74 columns. I've added indexes to the columns that I want to search on. Searching via a SQL query returns practically immediately (±100ms).



I wonder if it's slowing down because it's trying to search irrelevant attributes? The SQL server is processing during the whole time the search is ongoing. What can I do to speed this up? Is there some way to limit which attributes get searched, or ensure that the attributes I usually intend to search get checked first? Or is there another search method or plugin that will let me quickly search relevant attributes, without defaulting to searching all 74?










share|improve this question









New contributor




Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Which version of QGIS3? I'm on 3.4.5 and just tried a similar size/complexity of table and it worked quite quickly. The code seems to be this:- github.com/qgis/QGIS/blob/… . It seems to query all fields, matching feature at first match, and stops at 30 rows. The code looks as if it doesn't go back to the back-end, but it may be having to fetch from the database if you can't fit the whole table in RAM? Can you see any back-end queries arriving at postgres at all (e.g. using PGAdmin?)

    – Steven Kay
    Apr 5 at 18:57











  • @StevenKay 3.4.5 also. I should hope it goes to the backend, the whole table would take a while to transfer over the network. (I recently ran into the opposite problem with a different layer--QGIS reloads all PostGIS features when you pan the map.) Watching the PGAdmin dashboard, a session is "active" while the search is ongoing, and stops when the search is finished. Thanks for the link to the source code, that helps explain what it's doing.

    – Dan Getz
    Apr 5 at 19:26











  • @StevenKay unfortunately I haven't been able to spy on the queries themselves. I'm logging long queries but it's just showing the "FETCH FORWARD FROM" cursor instead of the query for that cursor. I wrote a query similar to what that code appears to be writing, and I can see that the planner won't want to use indexes if any of the string columns (of which this table has many!) doesn't have a trigram index on it. However, the query still only takes a few seconds, so I guess it's not the whole story.

    – Dan Getz
    Apr 5 at 19:44


















3















I'm using QGIS 3 with my data in a PostGIS server on the same local network. I want to quickly search for a feature based on a certain attribute or attributes of my layer. I've tried a couple methods, but keep running into performance much slower than it could be.



When I use the locator bar per this answer, I see some results quickly when I start typing the value, but when I type more it stops showing results, and I have to wait ±30 seconds before it finally finds the match.



When I use the Search Layers plugin, I get the match(es) practically immediately if I specify both the layer and the attribute. If it's set to "<All Layers>", or "<All Fields>", it takes a long time to return anything. However, if I close the plugin window and open it later, it defaults back to "<All Layers>".



This layer has ±2 million features, and 74 columns. I've added indexes to the columns that I want to search on. Searching via a SQL query returns practically immediately (±100ms).



I wonder if it's slowing down because it's trying to search irrelevant attributes? The SQL server is processing during the whole time the search is ongoing. What can I do to speed this up? Is there some way to limit which attributes get searched, or ensure that the attributes I usually intend to search get checked first? Or is there another search method or plugin that will let me quickly search relevant attributes, without defaulting to searching all 74?










share|improve this question









New contributor




Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Which version of QGIS3? I'm on 3.4.5 and just tried a similar size/complexity of table and it worked quite quickly. The code seems to be this:- github.com/qgis/QGIS/blob/… . It seems to query all fields, matching feature at first match, and stops at 30 rows. The code looks as if it doesn't go back to the back-end, but it may be having to fetch from the database if you can't fit the whole table in RAM? Can you see any back-end queries arriving at postgres at all (e.g. using PGAdmin?)

    – Steven Kay
    Apr 5 at 18:57











  • @StevenKay 3.4.5 also. I should hope it goes to the backend, the whole table would take a while to transfer over the network. (I recently ran into the opposite problem with a different layer--QGIS reloads all PostGIS features when you pan the map.) Watching the PGAdmin dashboard, a session is "active" while the search is ongoing, and stops when the search is finished. Thanks for the link to the source code, that helps explain what it's doing.

    – Dan Getz
    Apr 5 at 19:26











  • @StevenKay unfortunately I haven't been able to spy on the queries themselves. I'm logging long queries but it's just showing the "FETCH FORWARD FROM" cursor instead of the query for that cursor. I wrote a query similar to what that code appears to be writing, and I can see that the planner won't want to use indexes if any of the string columns (of which this table has many!) doesn't have a trigram index on it. However, the query still only takes a few seconds, so I guess it's not the whole story.

    – Dan Getz
    Apr 5 at 19:44














3












3








3








I'm using QGIS 3 with my data in a PostGIS server on the same local network. I want to quickly search for a feature based on a certain attribute or attributes of my layer. I've tried a couple methods, but keep running into performance much slower than it could be.



When I use the locator bar per this answer, I see some results quickly when I start typing the value, but when I type more it stops showing results, and I have to wait ±30 seconds before it finally finds the match.



When I use the Search Layers plugin, I get the match(es) practically immediately if I specify both the layer and the attribute. If it's set to "<All Layers>", or "<All Fields>", it takes a long time to return anything. However, if I close the plugin window and open it later, it defaults back to "<All Layers>".



This layer has ±2 million features, and 74 columns. I've added indexes to the columns that I want to search on. Searching via a SQL query returns practically immediately (±100ms).



I wonder if it's slowing down because it's trying to search irrelevant attributes? The SQL server is processing during the whole time the search is ongoing. What can I do to speed this up? Is there some way to limit which attributes get searched, or ensure that the attributes I usually intend to search get checked first? Or is there another search method or plugin that will let me quickly search relevant attributes, without defaulting to searching all 74?










share|improve this question









New contributor




Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm using QGIS 3 with my data in a PostGIS server on the same local network. I want to quickly search for a feature based on a certain attribute or attributes of my layer. I've tried a couple methods, but keep running into performance much slower than it could be.



When I use the locator bar per this answer, I see some results quickly when I start typing the value, but when I type more it stops showing results, and I have to wait ±30 seconds before it finally finds the match.



When I use the Search Layers plugin, I get the match(es) practically immediately if I specify both the layer and the attribute. If it's set to "<All Layers>", or "<All Fields>", it takes a long time to return anything. However, if I close the plugin window and open it later, it defaults back to "<All Layers>".



This layer has ±2 million features, and 74 columns. I've added indexes to the columns that I want to search on. Searching via a SQL query returns practically immediately (±100ms).



I wonder if it's slowing down because it's trying to search irrelevant attributes? The SQL server is processing during the whole time the search is ongoing. What can I do to speed this up? Is there some way to limit which attributes get searched, or ensure that the attributes I usually intend to search get checked first? Or is there another search method or plugin that will let me quickly search relevant attributes, without defaulting to searching all 74?







qgis postgis qgis-3 search






share|improve this question









New contributor




Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 5 at 20:43







Dan Getz













New contributor




Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 5 at 17:56









Dan GetzDan Getz

1165




1165




New contributor




Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Dan Getz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Which version of QGIS3? I'm on 3.4.5 and just tried a similar size/complexity of table and it worked quite quickly. The code seems to be this:- github.com/qgis/QGIS/blob/… . It seems to query all fields, matching feature at first match, and stops at 30 rows. The code looks as if it doesn't go back to the back-end, but it may be having to fetch from the database if you can't fit the whole table in RAM? Can you see any back-end queries arriving at postgres at all (e.g. using PGAdmin?)

    – Steven Kay
    Apr 5 at 18:57











  • @StevenKay 3.4.5 also. I should hope it goes to the backend, the whole table would take a while to transfer over the network. (I recently ran into the opposite problem with a different layer--QGIS reloads all PostGIS features when you pan the map.) Watching the PGAdmin dashboard, a session is "active" while the search is ongoing, and stops when the search is finished. Thanks for the link to the source code, that helps explain what it's doing.

    – Dan Getz
    Apr 5 at 19:26











  • @StevenKay unfortunately I haven't been able to spy on the queries themselves. I'm logging long queries but it's just showing the "FETCH FORWARD FROM" cursor instead of the query for that cursor. I wrote a query similar to what that code appears to be writing, and I can see that the planner won't want to use indexes if any of the string columns (of which this table has many!) doesn't have a trigram index on it. However, the query still only takes a few seconds, so I guess it's not the whole story.

    – Dan Getz
    Apr 5 at 19:44


















  • Which version of QGIS3? I'm on 3.4.5 and just tried a similar size/complexity of table and it worked quite quickly. The code seems to be this:- github.com/qgis/QGIS/blob/… . It seems to query all fields, matching feature at first match, and stops at 30 rows. The code looks as if it doesn't go back to the back-end, but it may be having to fetch from the database if you can't fit the whole table in RAM? Can you see any back-end queries arriving at postgres at all (e.g. using PGAdmin?)

    – Steven Kay
    Apr 5 at 18:57











  • @StevenKay 3.4.5 also. I should hope it goes to the backend, the whole table would take a while to transfer over the network. (I recently ran into the opposite problem with a different layer--QGIS reloads all PostGIS features when you pan the map.) Watching the PGAdmin dashboard, a session is "active" while the search is ongoing, and stops when the search is finished. Thanks for the link to the source code, that helps explain what it's doing.

    – Dan Getz
    Apr 5 at 19:26











  • @StevenKay unfortunately I haven't been able to spy on the queries themselves. I'm logging long queries but it's just showing the "FETCH FORWARD FROM" cursor instead of the query for that cursor. I wrote a query similar to what that code appears to be writing, and I can see that the planner won't want to use indexes if any of the string columns (of which this table has many!) doesn't have a trigram index on it. However, the query still only takes a few seconds, so I guess it's not the whole story.

    – Dan Getz
    Apr 5 at 19:44

















Which version of QGIS3? I'm on 3.4.5 and just tried a similar size/complexity of table and it worked quite quickly. The code seems to be this:- github.com/qgis/QGIS/blob/… . It seems to query all fields, matching feature at first match, and stops at 30 rows. The code looks as if it doesn't go back to the back-end, but it may be having to fetch from the database if you can't fit the whole table in RAM? Can you see any back-end queries arriving at postgres at all (e.g. using PGAdmin?)

– Steven Kay
Apr 5 at 18:57





Which version of QGIS3? I'm on 3.4.5 and just tried a similar size/complexity of table and it worked quite quickly. The code seems to be this:- github.com/qgis/QGIS/blob/… . It seems to query all fields, matching feature at first match, and stops at 30 rows. The code looks as if it doesn't go back to the back-end, but it may be having to fetch from the database if you can't fit the whole table in RAM? Can you see any back-end queries arriving at postgres at all (e.g. using PGAdmin?)

– Steven Kay
Apr 5 at 18:57













@StevenKay 3.4.5 also. I should hope it goes to the backend, the whole table would take a while to transfer over the network. (I recently ran into the opposite problem with a different layer--QGIS reloads all PostGIS features when you pan the map.) Watching the PGAdmin dashboard, a session is "active" while the search is ongoing, and stops when the search is finished. Thanks for the link to the source code, that helps explain what it's doing.

– Dan Getz
Apr 5 at 19:26





@StevenKay 3.4.5 also. I should hope it goes to the backend, the whole table would take a while to transfer over the network. (I recently ran into the opposite problem with a different layer--QGIS reloads all PostGIS features when you pan the map.) Watching the PGAdmin dashboard, a session is "active" while the search is ongoing, and stops when the search is finished. Thanks for the link to the source code, that helps explain what it's doing.

– Dan Getz
Apr 5 at 19:26













@StevenKay unfortunately I haven't been able to spy on the queries themselves. I'm logging long queries but it's just showing the "FETCH FORWARD FROM" cursor instead of the query for that cursor. I wrote a query similar to what that code appears to be writing, and I can see that the planner won't want to use indexes if any of the string columns (of which this table has many!) doesn't have a trigram index on it. However, the query still only takes a few seconds, so I guess it's not the whole story.

– Dan Getz
Apr 5 at 19:44






@StevenKay unfortunately I haven't been able to spy on the queries themselves. I'm logging long queries but it's just showing the "FETCH FORWARD FROM" cursor instead of the query for that cursor. I wrote a query similar to what that code appears to be writing, and I can see that the planner won't want to use indexes if any of the string columns (of which this table has many!) doesn't have a trigram index on it. However, the query still only takes a few seconds, so I guess it's not the whole story.

– Dan Getz
Apr 5 at 19:44











0






active

oldest

votes












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Dan Getz is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317927%2fsearches-on-layers-with-many-attributes-are-slow-despite-having-indexes-on-the-a%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Dan Getz is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Dan Getz is a new contributor. Be nice, and check out our Code of Conduct.












Dan Getz is a new contributor. Be nice, and check out our Code of Conduct.











Dan Getz is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317927%2fsearches-on-layers-with-many-attributes-are-slow-despite-having-indexes-on-the-a%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given

Romeo and Juliet ContentsCharactersSynopsisSourcesDate and textThemes and motifsCriticism and interpretationLegacyScene by sceneSee alsoNotes and referencesSourcesExternal linksNavigation menu"Consumer Price Index (estimate) 1800–"10.2307/28710160037-3222287101610.1093/res/II.5.31910.2307/45967845967810.2307/2869925286992510.1525/jams.1982.35.3.03a00050"Dada Masilo: South African dancer who breaks the rules"10.1093/res/os-XV.57.1610.2307/28680942868094"Sweet Sorrow: Mann-Korman's Romeo and Juliet Closes Sept. 5 at MN's Ordway"the original10.2307/45957745957710.1017/CCOL0521570476.009"Ram Leela box office collections hit massive Rs 100 crore, pulverises prediction"Archived"Broadway Revival of Romeo and Juliet, Starring Orlando Bloom and Condola Rashad, Will Close Dec. 8"Archived10.1075/jhp.7.1.04hon"Wherefore art thou, Romeo? To make us laugh at Navy Pier"the original10.1093/gmo/9781561592630.article.O006772"Ram-leela Review Roundup: Critics Hail Film as Best Adaptation of Romeo and Juliet"Archived10.2307/31946310047-77293194631"Romeo and Juliet get Twitter treatment""Juliet's Nurse by Lois Leveen""Romeo and Juliet: Orlando Bloom's Broadway Debut Released in Theaters for Valentine's Day"Archived"Romeo and Juliet Has No Balcony"10.1093/gmo/9781561592630.article.O00778110.2307/2867423286742310.1076/enst.82.2.115.959510.1080/00138380601042675"A plague o' both your houses: error in GCSE exam paper forces apology""Juliet of the Five O'Clock Shadow, and Other Wonders"10.2307/33912430027-4321339124310.2307/28487440038-7134284874410.2307/29123140149-661129123144728341M"Weekender Guide: Shakespeare on The Drive""balcony"UK public library membership"romeo"UK public library membership10.1017/CCOL9780521844291"Post-Zionist Critique on Israel and the Palestinians Part III: Popular Culture"10.2307/25379071533-86140377-919X2537907"Capulets and Montagues: UK exam board admit mixing names up in Romeo and Juliet paper"Istoria Novellamente Ritrovata di Due Nobili Amanti2027/mdp.390150822329610820-750X"GCSE exam error: Board accidentally rewrites Shakespeare"10.2307/29176390149-66112917639"Exam board apologises after error in English GCSE paper which confused characters in Shakespeare's Romeo and Juliet""From Mariotto and Ganozza to Romeo and Guilietta: Metamorphoses of a Renaissance Tale"10.2307/37323537323510.2307/2867455286745510.2307/28678912867891"10 Questions for Taylor Swift"10.2307/28680922868092"Haymarket Theatre""The Zeffirelli Way: Revealing Talk by Florentine Director""Michael Smuin: 1938-2007 / Prolific dance director had showy career"The Life and Art of Edwin BoothRomeo and JulietRomeo and JulietRomeo and JulietRomeo and JulietEasy Read Romeo and JulietRomeo and Julieteeecb12003684p(data)4099369-3n8211610759dbe00d-a9e2-41a3-b2c1-977dd692899302814385X313670221313670221