Stop using OFFSET in DB queries of phpBB3 importer

http://use-the-index-luke.com/no-offset
This commit is contained in:
Gerhard Schlager
2016-01-14 22:43:19 +01:00
parent 7f652e9d7f
commit e19ee93ee3
4 changed files with 65 additions and 38 deletions
@@ -3,7 +3,7 @@ require_relative '../support/constants'
module ImportScripts::PhpBB3
class Database_3_1 < Database_3_0
def fetch_users(offset)
def fetch_users(last_user_id)
query(<<-SQL)
SELECT u.user_id, u.user_email, u.username,
CASE WHEN u.user_password LIKE '$2y$%'
@@ -20,10 +20,9 @@ module ImportScripts::PhpBB3
u.user_id = b.ban_userid AND b.ban_exclude = 0 AND
(b.ban_end = 0 OR b.ban_end >= UNIX_TIMESTAMP())
)
WHERE u.user_type != #{Constants::USER_TYPE_IGNORE}
WHERE u.user_id > #{last_user_id} AND u.user_type != #{Constants::USER_TYPE_IGNORE}
ORDER BY u.user_id ASC
LIMIT #{@batch_size}
OFFSET #{offset}
SQL
end
end