Reputation: 4537
I have a big database of 2,600,000 records and I want to do some advanced searches on it by looping over all records. However, running a script with selectAll()
takes a very long time to load.
As a workaround, I'm looping over 100,000 records 26 times using this code:
for (i in 1..26) {
transaction {
for (app in AppsTable.selectAll().limit(n = 100000, offset = i * 100000L)) {
//..analysis
}
}
}
How can I speed up this query or if possible how can I reduce the query set by queries just the columns I need to work with? For eg, can I do something like this -
AppsTable.selectAll(AppsTable.name, AppsTable.downloadCount, AppsTable.developerId)
Upvotes: 1
Views: 2404
Reputation: 71
Just use the slice()
method before selectAll()
like this:
AppsTable.slice(AppsTable.name, AppsTable.downloadCount, AppsTable.developerId)
.selectAll()
.limit(n = 100000, offset = i * 100000L)
Upvotes: 3