blazer icon indicating copy to clipboard operation
blazer copied to clipboard

[Idea] Limit setting for queries

Open VicenteFava opened this issue 5 years ago • 7 comments

Hi,

What do you think about having a limit setting that applies to all the queries if it is set? The idea of this is to prevent the database or the server from having performance issues when executing queries that grab a large amount of data.

If you think that this can be helpful I can do a PR with the code. Thanks!

VicenteFava avatar Nov 20 '19 17:11 VicenteFava

Hey @VicenteFava, thanks for the suggestion! For the database, it's best to set a statement timeout to limit the impact of individual queries. For the server, it'd be good to benchmark where most of the time is spent for large result sets to help decide what to do and test potential solutions. I think a row_limit option would likely help - we'd just need to make it clear to users when the results were limited (including for cached results).

ankane avatar Dec 06 '19 04:12 ankane

Hi @ankane, we are using Blazer for some visualizations as well as custom reports. We'd also like to have something like a row_limit for the web view, to limit results which are displayed (or maybe we think of it akin to pagination), while still indicating the total row count.

I've looked at the code and there are several ins and outs that make it hard to know the best place to introduce this limit. We're just looking for a limit on what is displayed in a tabular view. Limiting data for charts isn't a focus for us at the moment. Just tabular view, with the ability to then download the full results.

Could you give some pointers of where best to look at implementing this? I'm happy to put a PR together.

Thanks!

joelvh avatar May 28 '20 17:05 joelvh

A nice feature in addition to this would be to impose the row limits on the display version of the results, but allow for downloading the CSV of the full report results.

rdlugosz avatar Jun 02 '21 12:06 rdlugosz

#311 PR has already addressed limiting the number of html views only.

aki77 avatar Jun 02 '21 12:06 aki77

@aki77 +1 to #311. It would be valuable to our team, too. We're forking to include it, but would prefer to stay on the core gem for updates.

@ankane Any thoughts or concerns regarding merging in #311 that would give you pause to merging it in?

Workman avatar Oct 15 '21 16:10 Workman

I've come across the problem in my organization, is there plans to introduce this feature?

@Workman Is your fork public?

tiagotex avatar Feb 08 '22 13:02 tiagotex

Until the PRs are merged, I am using the following monkey patch.

app/controllers/blazer/queries_controller.rb

require Blazer::Engine.root.join('app/controllers/blazer/queries_controller.rb')

module BlazerQueriesControllerExtention
  def render_run
    if request.format == :html && Blazer.settings['row_limit']
      @row_limit ||= Blazer.settings['row_limit']
    end

    super
  end
end

Blazer::QueriesController.prepend(BlazerQueriesControllerExtention)

config/blazer.yml

row_limit: 5000

aki77 avatar Aug 28 '22 07:08 aki77