# How to change the response default\_limit in data explorer?

**URL:** https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150
**Category:** Development
**Tags:** data-explorer
**Created:** [January 7, 2022, 3:09pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150 "2022-01-07T15:09:44Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Donavan\_Martin1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donavan_martin1/32/243280_2.png) [@Donavan\_Martin1](https://meta.discourse.org/u/Donavan_Martin1)
#### Post date: [January 7, 2022, 3:09pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/1 "2022-01-07T15:09:44Z")

</div>

Hi,

What is the best way to set the default\_limit to something like 12345678 ?  
Suppose that I need and I want more than 1000 rows.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 7, 2022, 6:06pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/2 "2022-01-07T18:06:28Z")

</div>

I can’t figure out what `default_limit` you’re talking about. I don’t see that in `site_settings.yml`. What are you trying to do? And are you trying to do it in a plugin or theme component (since you posted in dev)?

---

<div class="post-metadata">

### Author: ![Donavan\_Martin1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donavan_martin1/32/243280_2.png) [@Donavan\_Martin1](https://meta.discourse.org/u/Donavan_Martin1)
#### Post date: [January 7, 2022, 11:09pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/3 "2022-01-07T23:09:16Z")

</div>

The data-explorer plugin’s default\_limit…

 ![Capture d’écran, le 2022-01-07 à 18.07.22](https://global.discourse-cdn.com/meta/original/3X/e/0/e0560d6766f744b20a062eb42e4cbdff0bc31728.png)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 7, 2022, 11:31pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/4 "2022-01-07T23:31:55Z")

</div>

> [@How to bump 10k records csv export limit in Data Explorer?](https://meta.discourse.org/t/how-to-bump-10k-records-csv-export-limit-in-data-explorer/210520):
>
> I need a CSV export of data that goes beyond 10k rows in the CSV export, this is resulting in not all records being exported. Assuming this line is responsible for the said limit What will be the right way to bump this limit to maybe 100k or 1M records? I tried doing DISCOURSE\_QUERY\_RESULT\_MAX\_LIMIT = 1000000 in app.yml and that doesn’t seem to have any effect.

---

<div class="post-metadata">

### Author: ![Donavan\_Martin1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donavan_martin1/32/243280_2.png) [@Donavan\_Martin1](https://meta.discourse.org/u/Donavan_Martin1)
#### Post date: [January 8, 2022, 8:49pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/5 "2022-01-08T20:49:49Z")

</div>

Ok, the only way is to set another value like this:  
I was hoping there was a better way in Discourse’s settings UI.

```plaintext
./launcher enter app
cd /var/www/discourse/plugins/discourse-data-explorer/
sed -i 's/QUERY_RESULT_DEFAULT_LIMIT = 1000/QUERY_RESULT_DEFAULT_LIMIT = 12345678/g' /var/www/discourse/plugins/discourse-data-explorer/plugin.rb
sed -i 's/QUERY_RESULT_MAX_LIMIT = 1000/QUERY_RESULT_MAX_LIMIT = 12345678/g' /var/www/discourse/plugins/discourse-data-explorer/plugin.rb

```

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 8, 2022, 9:58pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/6 "2022-01-08T21:58:08Z")

</div>

> [@Donavan\_Martin1](#):
>
> the only way

Certainly not the only way.

As per my link, you can fork the plugin, change the constant and clone your fork.

You could always PR a plugin setting to that plugin …

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 9, 2022, 11:29am UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/7 "2022-01-09T11:29:41Z")

</div>

Not the only way. It’s possible to make changes like that with launcher. You can log at the other templates for examples of how to make changes to files.

---

<div class="post-metadata">

### Author: ![Donavan\_Martin1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donavan_martin1/32/243280_2.png) [@Donavan\_Martin1](https://meta.discourse.org/u/Donavan_Martin1)
#### Post date: [January 9, 2022, 2:01pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/8 "2022-01-09T14:01:36Z")

</div>

If this isn’t the only way, can you provide an example thanks.

---

<div class="post-metadata">

### Author: ![Donavan\_Martin1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donavan_martin1/32/243280_2.png) [@Donavan\_Martin1](https://meta.discourse.org/u/Donavan_Martin1)
#### Post date: [February 13, 2022, 4:06pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/9 "2022-02-13T16:06:18Z")

</div>

They recently change the code to a new hidden settings…

[https://github.com/discourse/discourse-data-explorer/commit/70b973ea9a5290614d7ddd772433c2f6fcca7cba#r66512267](https://github.com/discourse/discourse-data-explorer/commit/70b973ea9a5290614d7ddd772433c2f6fcca7cba#r66512267)

---

<div class="post-metadata">

### Author: ![Donavan\_Martin1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donavan_martin1/32/243280_2.png) [@Donavan\_Martin1](https://meta.discourse.org/u/Donavan_Martin1)
#### Post date: [February 13, 2022, 4:28pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/10 "2022-02-13T16:28:35Z")

</div>

```plaintext
cd /var/discourse
./launcher enter app
sed -i 's/QUERY_RESULT_DEFAULT_LIMIT = 1000/QUERY_RESULT_DEFAULT_LIMIT = 10000000/g' /var/www/discourse/plugins/discourse-data-explorer/plugin.rb
sed -i 's/QUERY_RESULT_MAX_LIMIT = 1000/QUERY_RESULT_MAX_LIMIT = 10000000/g' /var/www/discourse/plugins/discourse-data-explorer/plugin.rb
sed -i 's/default: 1000/default: 10000000/g' plugins/discourse-data-explorer/config/settings.yml
sed -i 's/max: 10000/max: 10000000/g' plugins/discourse-data-explorer/config/settings.yml
rails c
SiteSetting.data_explorer_query_result_limit=1000000
exit
exit
reboot

```

---

<div class="post-metadata">

### Author: ![n1bff](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@n1bff](https://meta.discourse.org/u/n1bff)
#### Post date: [November 7, 2023, 10:29pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/11 "2023-11-07T22:29:39Z")

</div>

How can one change such a “hidden setting” in the most forward way?

I hope it does not require editing code to change such a basic limit of the plugin.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 7, 2023, 11:16pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/12 "2023-11-07T23:16:57Z")

</div>

You can change a hidden site setting using the rails console (if you have server access).

```plaintext
cd /var/discourse
./launcher enter app
rails c
SiteSetting.data_explorer_query_result_limit = 10000

```

Though the upper limit is 10,000, and I believe this is only the number of results that are displayed ‘on-screen’ - you can already export 10,000 results even with the setting at the default 1000.

> <https://github.com/discourse/discourse-data-explorer/blob/main/config/settings.yml#L5>

I think adding a page offset to your query is useful if you want to grab batches to export and join together in a spreadsheet (etc). eg:

```sql
-- [params]
-- integer :page = 0
-- integer :limit = 10000

SELECT 
    category_id,
    created_at::date,
    id AS topic_id,
    views
FROM topics
WHERE deleted_at IS NULL
ORDER BY created_at DESC
OFFSET :page * :limit
LIMIT :limit

```

---

<div class="post-metadata">

### Author: ![n1bff](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@n1bff](https://meta.discourse.org/u/n1bff)
#### Post date: [November 8, 2023, 5:27pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/13 "2023-11-08T17:27:37Z")

</div>

I only got 1000 results when querying a query via the API and considering the significant overhead per request (factor 100 to the raw request to the database) I rather increase that limit than do multiple queries. :slight_smile:

Is that rail console approach persistent over software upgrades and restarts?

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 8, 2023, 6:49pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/14 "2023-11-08T18:49:41Z")

</div>

Changing a site setting via the rails console is the same as doing it through the UI (just for the hidden ones there is no UI :slight_smile:), so the change will stick and not be affected by rebuilds or restarts, etc. :+1:

My knowledge on running them through the API is not as good as the regular way, but I think there’s a method of getting the full 10,000 without changing the setting in the rails console in this topic - [Run Data Explorer queries with the Discourse API](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063)

---

<div class="post-metadata">

### Author: ![n1bff](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@n1bff](https://meta.discourse.org/u/n1bff)
#### Post date: [November 9, 2023, 4:10pm UTC](https://meta.discourse.org/t/how-to-change-the-response-default-limit-in-data-explorer/214150/15 "2023-11-09T16:10:27Z")

</div>

Thank you, that [`limit=ALL`](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063#handling-queries-that-return-over-1000-rows-1) parameter solves it for me.
