# Jdbc\_input\_plugin : extra count query with paging disabled

**URL:** <https://discuss.elastic.co/t/jdbc-input-plugin-extra-count-query-with-paging-disabled/227212>\
**Category:** Logstash\
**Created:** [April 8, 2020, 9:37pm UTC](https://discuss.elastic.co/t/jdbc-input-plugin-extra-count-query-with-paging-disabled/227212 "2020-04-08T21:37:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deslauriersp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deslauriersp/32/47685_2.png) [@deslauriersp](https://discuss.elastic.co/u/deslauriersp)\
**Post date:** [April 8, 2020, 9:37pm UTC](https://discuss.elastic.co/t/jdbc-input-plugin-extra-count-query-with-paging-disabled/227212/1 "2020-04-08T21:37:38Z")

</div>

I am trying to setup a JDBC input plugin.  
I have turned off paging :

> jdbc\_paging\_enabled =\> false  
> jdbc\_page\_size =\> 0

Yet, in the "debug" logs I can see

`SELECT count(*) "COUNT" FROM ( [my_query] ) "T1" FETCH NEXT 1 ROWS ONLY`

This is a problem for me, since the query will never return the same thing twice.

Since Logstash does not work in cluster, we are trying to "split" the work at the one place all instances are accessing : the DB. We built a query that will return a different chunk everytime, and paging is handled in the DB size. Since each query will return a different result, you can understand why the extra "count" query is problematic

The goal is to indexing X millions records, splitting the load across logstash nodes, and don't index anything twice.

Is there a way to disable this extra "count" query?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 8, 2020, 11:34pm UTC](https://discuss.elastic.co/t/jdbc-input-plugin-extra-count-query-with-paging-disabled/227212/2 "2020-04-08T23:34:52Z")

</div>

> [@deslauriersp](#):
>
> Is there a way to disable this extra "count" query?

I do not think so. The [open issue](https://github.com/logstash-plugins/logstash-input-jdbc/issues/305) is still open.

---

<div class="post-metadata">

**Author:** ![deslauriersp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deslauriersp/32/47685_2.png) [@deslauriersp](https://discuss.elastic.co/u/deslauriersp)\
**Post date:** [April 9, 2020, 3:19am UTC](https://discuss.elastic.co/t/jdbc-input-plugin-extra-count-query-with-paging-disabled/227212/3 "2020-04-09T03:19:58Z")

</div>

I found a workaround.

I used a “prepared statement” with no parameters.

Thanks for pointing out the issue on github.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 7, 2020, 3:20am UTC](https://discuss.elastic.co/t/jdbc-input-plugin-extra-count-query-with-paging-disabled/227212/4 "2020-05-07T03:20:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
