Skip to content

Slow running Recursive CTE #409

Closed
Closed

Description

@sprintel

Sqlitebrowser performs very slow when running Recursive CTE. I have a table with >500K rows and it takes Sqlitebrowser about 6 minutes to finish the query. Other sqlite browsers/managers such as sqlitespy, database.net, etc take around 1 min and 45 sec to complete. The fastest is sqlitespeed. It takes only about 1 min and 15 sec to complete the query. Can somebody take a look at this?

Thanks

Activity

  1. justinclift commented on Aug 28, 2015

    @justinclift
    Member

    Are you able to share the database and slow query with us? Emailing it to me directly (justin@postgresql.org) is workable, if that helps. 😄

  2. justinclift commented on Aug 28, 2015

    @justinclift
    Member

    Received it. Have now forwarded it onto @MKleusberg (CC-ing yourself), in the hope he has time to investigate. 😄

  3. sprintel commented on Oct 29, 2015

    @sprintel
    Author

    Justin -
    Any update? Did he get a chance to investigate?
    Thanks,
    AJ

  4. MKleusberg commented on Feb 17, 2017

    @MKleusberg
    Member

    Thanks for reminding me @sprintel and sorry for the delay! The main problem here is that we have to execute this query essentially twice. One time for getting the total row count like this:

    SELECT COUNT(*) FROM (...);

    And one time for actually getting the first block of data:

    WITH RECURSIVE ... LIMIT 0,50000;

    This explains why it's taking so much longer. The issue here is that we need to know the total row count before doing anything else to get the scrolling in the result view right. But this doesn't explain why it's taking 6 minutes for you. It should really "just" be 3 and a bit.

    So out of curiosity, how long does it take on your system using the latest nightly build? Any improvement yet? If not, maybe we can provide you with a build that outputs some more debug information in order to find out where the extra time is coming from.

    Another question would be if it might be a good idea to add a new option to the preferences dialog for disabling the COUNT(*) thing. The cost of this would be less information when browsing and very jumpy scrolling.

  5. justinclift commented on Feb 17, 2017

    @justinclift
    Member

    @MKleusberg As a thought, if we add debugging output to the build maybe we should leave it in and have it toggled on/off by a command line switch or something?

  6. sprintel commented on Feb 17, 2017

    @sprintel
    Author

    @MKleusberg - I recently got a new PC so I have different results when I tested the sample that I sent you. The latest DB browser (v3.9.1) now can complete the query in 149 second (2.5 minute) vs 68 second if I use sqlitespy. With my old PC, DB browser took 6 minutes to finish the query vs 1 min and 45 with sqlitespy. It seems DB browser processes the query faster but still lags behind other sqlite browsers.

    I'm more than happy to help you run the query using the special build to figure out the issue. Just let me know.

  7. justinclift commented on Feb 17, 2017

    @justinclift
    Member

    @MKleusberg As an "out there" idea, remember how we add a Qt regex function upon startup? Don't suppose the presence of that might affect the communication path or something?

  8. MKleusberg commented on Mar 16, 2017

    @MKleusberg
    Member

    @justinclift Nah, that only gets called when you're actually performing a regex operation, i.e. not when simply browsing a table. The problem seems to be that we're essentially performing each query twice.

  9. mgrojo commented on Oct 4, 2018

    @mgrojo
    Member

    @MKleusberg, might this be better with the current build?

  10. MKleusberg commented on Oct 15, 2018

    @MKleusberg
    Member

    @mgrojo Unfortunately not. I vaguely remember some changes I did a long time ago to slightly improve the performance for the Execute SQL tab but other than that nothing really changed. Even though we now have the multithreaded loading of data in place, the code for the Execute SQL tab doesn't profit from it. That's also why #1563 doesn't work for the Execute SQL tab - it would work, but because the main thread is stopped until the loading is done, you can't click the button. I am however working on this right now. In two days or so I hope to present a first prototype 😄

  11. MKleusberg commented on Oct 18, 2018

    @MKleusberg
    Member

    @sprintel Are you still interested in this issue? I'm asking because we are currently preparing some changes which might improve this. I'm still not sure how to further improve the performance in any noticeable way, but I think the version we have prepared is 1) again a bit faster and 2) has a cancel button. Do you want to give it a try? You can find the Windows and OSX build here:

  12. self-assigned this
    on Oct 18, 2018
  13. sprintel commented on Oct 18, 2018

    @sprintel
    Author

    I actually stop using this software because of the slow speed. I would like to test it but I'm wondering if you have a portable version that I can use. I'm allowed to use this software (it's approved) in my company but to install a program, it's such a hassle to go through the bureaucracy.

  14. sprintel commented on Oct 18, 2018

    @sprintel
    Author

    Never mind about the portable request. I'm able to extract the files from the installer and run it. I'll let you know.

  15. justinclift commented on Oct 18, 2018

    @justinclift
    Member

    We're already getting reports of a bunch of bugs (in #1575) with these v1 and v2 builds. Probably not good to use them on production data. 😉

  16. sprintel commented on Oct 18, 2018

    @sprintel
    Author

    I just tested it.
    Other software: 222 Sec completely loaded
    v.3.5.1 691 Sec completely loaded
    v 3.11.999:
    -185 Sec but not loaded at all (1st trial).
    -253 Sec but partially loaded (2nd trial).
    -Completely loaded took 345 Sec (see attached pic)
    sqlite db browser snapshot

  17. sprintel commented on Oct 18, 2018

    @sprintel
    Author

    I just reran my other software and I took only 102 Sec this time. I also ran dbeaver and it took 90 sec.

  18. justinclift commented on Oct 18, 2018

    @justinclift
    Member

    Thanks @sprintel, that's good info. 😄

  19. MKleusberg commented on Jan 11, 2021

    @MKleusberg
    Member

    Are you still around, @sprintel? It took a long time but the current nightly build of DB4S is finally running your query at full speed. If you want to you can give it a try and tell us if it's working as expected. Or we can just close this issue as it's pretty old.

  20. sprintel commented on Jan 11, 2021

    @sprintel
    Author

    I’m still here but I already moved to a different job and don’t use sqlite anymore. I will ask somebody from my old team to test if they have time.

  21. justinclift commented on Jan 13, 2021

    @justinclift
    Member

    Thanks @sprintel, that'd be great! 😄

  22. sprintel commented on Jan 13, 2021

    @sprintel
    Author

    Unfortunately my old team already switched to a different sqlite browser. Since nobody will be testing it, I’m going to go ahead and close the ticket.

  23. justinclift commented on Jan 13, 2021

    @justinclift
    Member

    No worries, was a thought. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions