# Only import new or updated rows using JDBC

**URL:** https://discuss.elastic.co/t/only-import-new-or-updated-rows-using-jdbc/76152
**Category:** Logstash
**Created:** [February 23, 2017, 5:58am UTC](https://discuss.elastic.co/t/only-import-new-or-updated-rows-using-jdbc/76152 "2017-02-23T05:58:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Reno](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reno/32/15674_2.png) [@Reno](https://discuss.elastic.co/u/Reno)
#### Post date: [February 23, 2017, 5:58am UTC](https://discuss.elastic.co/t/only-import-new-or-updated-rows-using-jdbc/76152/1 "2017-02-23T05:58:23Z")

</div>

Right now I've got Logstash importing a miniature version of my MSSQL database, using the JDBC plugin. I've got each JDBC input scheduled to run every minute to update Elasticsearch. To update, I'm currently just re-importing every single table and row in my database, and adding all rows to Elasticsearch. When I begin using the full database though, this will be very inefficient as it will take more than a minute to go through the entire database. Is there another way to keep Elasticsearch in sync with my database? I've tried to use the 'sql\_last\_value' parameter to only import new rows into the database, but this will only work when the 'id' for my database table is a number, and each new entry in the table has a greater number than the last. Some tables in the database have an 'id' which can be completely random (ie. "43f4-f43ef-e44454r"), which cannot be used with 'sql\_last\_value' as they are impossible to compare. I'm also unable modify the actual database at all, which cuts out a lot of my potential solutions. I feel as if i am out of options here, so can anyone suggest anything that I can try?

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [February 23, 2017, 6:52am UTC](https://discuss.elastic.co/t/only-import-new-or-updated-rows-using-jdbc/76152/2 "2017-02-23T06:52:10Z")

</div>

Is there any other column that you can use? Something that indicates a last modification date? If not you seem to be out of luck. Logstash can't detect what's new without some help.

---

<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: [March 23, 2017, 6:52am UTC](https://discuss.elastic.co/t/only-import-new-or-updated-rows-using-jdbc/76152/3 "2017-03-23T06:52:12Z")

</div>

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