# JDBC plugin query taking too long to run

**URL:** <https://discuss.elastic.co/t/jdbc-plugin-query-taking-too-long-to-run/87638>\
**Category:** Logstash\
**Created:** [May 30, 2017, 9:32pm UTC](https://discuss.elastic.co/t/jdbc-plugin-query-taking-too-long-to-run/87638 "2017-05-30T21:32:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asharma](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@asharma](https://discuss.elastic.co/u/asharma)\
**Post date:** [May 30, 2017, 9:32pm UTC](https://discuss.elastic.co/t/jdbc-plugin-query-taking-too-long-to-run/87638/1 "2017-05-30T21:32:55Z")

</div>

Hi,  
I am interested in how logstash handles scheduled jdbc inputs.  
If I schedule the jdbc input plugin to read some data every 5 mins but the query itself takes around 10 mins to run depending on server load.  
How will logstash react in this case ? will it try to run data every 5 mins or will it wait for the first schedule batch to complete and then start the next scheduled batch ?

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [May 31, 2017, 9:08am UTC](https://discuss.elastic.co/t/jdbc-plugin-query-taking-too-long-to-run/87638/2 "2017-05-31T09:08:11Z")

</div>

I have not tested this myself, but reading the code and issues in Github indicates that because the next scheduled task's run time would be in the past - the scheduler runs that task immediately. Also note that the scheduler calculates the next tasks run time at the end of the previous task - this means that some times in the cron schedule might be skipped.

Look into using a Materialized View or similar.

---

<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:** [June 28, 2017, 9:08am UTC](https://discuss.elastic.co/t/jdbc-plugin-query-taking-too-long-to-run/87638/3 "2017-06-28T09:08:15Z")

</div>

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