# How to load big table to es with logstash

**URL:** <https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502>\
**Category:** Logstash\
**Created:** [September 6, 2017, 2:46am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502 "2017-09-06T02:46:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaobo\_yu](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gaobo\_yu](https://discuss.elastic.co/u/gaobo_yu)\
**Post date:** [September 6, 2017, 2:46am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502/1 "2017-09-06T02:46:51Z")

</div>

Hi :  
I hava a mysql table named "orders" with ten million records ,I am trying to import all the data to Es with the plugin logstash-input-jdbc, but it seems cost a long time to finish this task, I have optimized all the params as far as I know,such as the mysql "useCursorFetch=true" ,"jdbc\_fetch\_size","jdbc\_paging\_enabled" ,but seems not work as I expected. Could anyone help me solve this problem;Thanks in advance;

my logstash config file is as below:

input {  
stdin {  
}  
jdbc {  
# mysql jdbc connection string to our backup databse  
jdbc\_connection\_string =\> "jdbc:mysql://dev.mysql.xxx.so:3306/test?useCursorFetch=true"  
# the user we wish to excute our statement as  
jdbc\_user =\> "user"  
jdbc\_password =\> "test"  
# the path to our downloaded jdbc driver  
jdbc\_driver\_library =\> "/home/api/mysql-connector-java-5.1.25.jar"  
# the name of the driver class for mysql  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_paging\_enabled =\> "true"  
jdbc\_fetch\_size =\> "50000"  
statement\_filepath =\> "../jdbc.sql"  
schedule =\> "\*/2 \* \* \* \* \*"  
type =\> "jdbc"  
}  
}

filter {  
json {  
source =\> "message"  
remove\_field =\> ["message"]  
}  
}

output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "test"  
document\_type =\> "orders"  
document\_id =\> "%{id}"  
}

And the jdbc.sql file context is :  
select \* from orders

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 6, 2017, 3:02am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502/2 "2017-09-06T03:02:09Z")

</div>

How long?

---

<div class="post-metadata">

**Author:** ![gaobo\_yu](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gaobo\_yu](https://discuss.elastic.co/u/gaobo_yu)\
**Post date:** [September 6, 2017, 3:07am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502/3 "2017-09-06T03:07:23Z")

</div>

I have improted 3100000 records to es ,and takes about 50 minutes, the store.size on es is 2.1GB

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 6, 2017, 3:29am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502/4 "2017-09-06T03:29:02Z")

</div>

What sort of monitoring do you have in place to tell if it's the DB or Elasticsearch/Logstash?

---

<div class="post-metadata">

**Author:** ![gaobo\_yu](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gaobo\_yu](https://discuss.elastic.co/u/gaobo_yu)\
**Post date:** [September 7, 2017, 3:10am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502/5 "2017-09-07T03:10:38Z")

</div>

I use the ELK tools with logstash-input-jdbc , there is no other monitoring tools.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 7, 2017, 5:21am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502/6 "2017-09-07T05:21:26Z")

</div>

I would recommend running the configuration once while replacing the elasticsearch output with e.g. a file output. That way you can check what the throughput of reading from the database is. Also monitor how much CPU you are using while doing this.

---

<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:** [October 5, 2017, 5:21am UTC](https://discuss.elastic.co/t/how-to-load-big-table-to-es-with-logstash/99502/7 "2017-10-05T05:21:32Z")

</div>

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