Allow using a different query for counting

Created on 5 April 2023, over 1 year ago

Problem/Motivation

Fetching every result and counting them in CustomSQLQuery::count() can be quite slow for large queries.

Steps to reproduce

  1. Use a slow query with a lot of results in sql_query.
  2. Run drush migrate:status.
  3. Counting is slow.

Proposed resolution

We could add a sql_count_query option with a different query.
It would allow us to do something like this:

sql_count_query: 'SELECT COUNT(*) FROM foo' # COUNT(*) is usually pretty fast
sql_query: 'SELECT * FROM foo' # Slow query with a lot of results
Feature request
Status

Needs review

Version

1.3

Component

Code

Created by

🇫🇷France prudloff Lille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024