Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connections api results widget #44051

Merged
merged 63 commits into from
Jul 10, 2021
Merged

Conversation

elpaso
Copy link
Contributor

@elpaso elpaso commented Jul 5, 2021

Description

This is the implementation of QGIS Enhancement: Port DB Manager Table Management Functionalities to Browser: SQL execution (part 3) qgis/QGIS-Enhancement-Proposals#205

qgis-queryresultwidget-final2

Features

  • SQL dialog available from browser panel for:
    • DB connections
    • Schema items
    • Table items
  • Multi-threaded implementation for both API token fetching and row fetching: no GUI blocking
  • Fully interruptible API
  • Progressive loading of features in the results view (fetchMore API)

@github-actions github-actions bot added this to the 3.22.0 milestone Jul 5, 2021
@nyalldawson
Copy link
Collaborator

Looking great! Can I suggest a small refinement to the fetch more behaviour? I think good logic could be:

  1. Fetch the first 200 rows only upfront
  2. On the first request to fetch more, start retrieving ALL the remaining rows

This would give users an opportunity to see if they've made an error in their SQL immediately before we go ahead and fetch all the results (potentially avoiding unwanted expensive database work), but also allow the full advantage of your threaded model to fetch all results so that they're ready for the user "in advance". Make sense?

src/app/browser/qgsinbuiltdataitemproviders.cpp Outdated Show resolved Hide resolved
src/app/browser/qgsinbuiltdataitemproviders.cpp Outdated Show resolved Hide resolved
src/app/browser/qgsinbuiltdataitemproviders.cpp Outdated Show resolved Hide resolved
src/gui/qgsqueryresultwidget.cpp Show resolved Hide resolved
src/gui/qgsqueryresultwidget.cpp Outdated Show resolved Hide resolved
src/gui/qgsqueryresultwidget.cpp Outdated Show resolved Hide resolved
src/gui/qgsqueryresultwidget.cpp Outdated Show resolved Hide resolved
src/gui/qgsqueryresultwidget.h Outdated Show resolved Hide resolved
@elpaso
Copy link
Contributor Author

elpaso commented Jul 6, 2021

Looking great! Can I suggest a small refinement to the fetch more behaviour? I think good logic could be:

1. Fetch the first 200 rows only upfront

2. On the first request to fetch more, start retrieving ALL the remaining rows

This would give users an opportunity to see if they've made an error in their SQL immediately before we go ahead and fetch all the results (potentially avoiding unwanted expensive database work), but also allow the full advantage of your threaded model to fetch all results so that they're ready for the user "in advance". Make sense?

I would rather prefer to leave it like it is now, the reason is that fetching ALL rows in case of a huge DB could crash QGIS due to out of memory conditions.

Probably we could achieve the best of both solutions by pre-fetching a certain number of features and keeping them in a cache but I'm not sure it worths the added complexity.

@elpaso elpaso force-pushed the connections-api-results-widget branch from 6d4e64c to 78a42cf Compare July 6, 2021 20:38
src/app/browser/qgsinbuiltdataitemproviders.cpp Outdated Show resolved Hide resolved
src/core/providers/ogr/qgsgeopackageproviderconnection.cpp Outdated Show resolved Hide resolved
src/core/providers/qgsabstractdatabaseproviderconnection.h Outdated Show resolved Hide resolved
src/core/providers/qgsabstractdatabaseproviderconnection.h Outdated Show resolved Hide resolved
src/core/providers/qgsabstractdatabaseproviderconnection.h Outdated Show resolved Hide resolved
src/core/providers/qgsabstractdatabaseproviderconnection.h Outdated Show resolved Hide resolved
src/core/qgis.h Outdated Show resolved Hide resolved
src/core/qgis.h Outdated Show resolved Hide resolved
src/core/qgis.h Show resolved Hide resolved
@nyalldawson
Copy link
Collaborator

I would rather prefer to leave it like it is now, the reason is that fetching ALL rows in case of a huge DB could crash QGIS due to out of memory conditions.

Fair enough. The thing I'm not so taken with is the progress bar shown in the GUI which only progresses as the table is scrolled. To me that's a bit odd UI -- I could imagine a user sitting and waiting for ever for the progress bar to complete, thinking that the query is still running and that they need to wait before they can do anything. Maybe just remove the bar entirely?

@elpaso
Copy link
Contributor Author

elpaso commented Jul 7, 2021

I would rather prefer to leave it like it is now, the reason is that fetching ALL rows in case of a huge DB could crash QGIS due to out of memory conditions.

Fair enough. The thing I'm not so taken with is the progress bar shown in the GUI which only progresses as the table is scrolled. To me that's a bit odd UI -- I could imagine a user sitting and waiting for ever for the progress bar to complete, thinking that the query is still running and that they need to wait before they can do anything. Maybe just remove the bar entirely?

You are right, to explain the genesis of the progress bar:

  1. I first introduced it to make it clear that something is happening (indeterminate state) while performing the query execution (the first step)
  2. the original implementation was fetching all rows (0-100 %, standard progress bar)

Now, I'd like to keep the progress bar while doing the query execution in step 1. For the fetching step I'm ok, to leave the feature fetched counter and remove the progress bar (or maybe just show-hide it briefly when the actual fetching is happening, it may be slow on certain connections).

About the execution time of step 1, we need to show it all the times because the step 2 starts immediately after step 1 is completed.

@nyalldawson
Copy link
Collaborator

@elpaso

Now, I'd like to keep the progress bar while doing the query execution in step 1. For the fetching step I'm ok, to leave the feature fetched counter and remove the progress bar (or maybe just show-hide it briefly when the actual fetching is happening, it may be slow on certain connections).

Sounds good to me!

@elpaso elpaso merged commit 91370a9 into qgis:master Jul 10, 2021
@elpaso elpaso deleted the connections-api-results-widget branch July 10, 2021 13:30
@nyalldawson
Copy link
Collaborator

Great work Alessandro -- you should be very proud of this one!!

@elpaso
Copy link
Contributor Author

elpaso commented Jul 11, 2021

@nyalldawson thank you for reviewing this and for the valuable advice!

@@ -52,6 +54,12 @@ bool QgsHanaProviderResultIterator::hasNextRowPrivate() const
return mNextRow;
}

long long QgsHanaProviderResultIterator::rowCountPrivate() const
{
// TODO: hana team, this is for you.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrylov Can you take care of the implementation and check whether we have or should implement additional methods?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will take a closer look.

@zacharlie zacharlie added the Changelog Items that are queued to appear in the visual changelog - remove after harvesting label Sep 19, 2021
@zacharlie zacharlie added ChangelogHarvested This PR description has been harvested in the Changelog already. and removed Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Sep 26, 2021
@sigeal
Copy link

sigeal commented Mar 24, 2022

Can you please have a look at this issue :
#47906

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChangelogHarvested This PR description has been harvested in the Changelog already. Feature QGIS Browser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants