Postgres driver uses ILIKE statement to make conditions case insensitive. That makes queries a way slower.

I used the following snippet for benchmarking.

$etm = \Drupal::entityTypeManager();
$query = $etm->getStorage('node')
  ->getQuery()
  ->accessCheck(FAlSE)
  ->condition('title', 'test');

echo $query, \PHP_EOL;
echo '--------------', \PHP_EOL;

$start = \microtime(TRUE);
$ids = $query->execute();
$end = \microtime(TRUE);

echo \number_format(1000 * ($end - $start), 3), ' ms', \PHP_EOL;

On my localhost with ~50k nodes dropping LIKE -> ILIKE replacement makes this query 30 times faster.

CommentFileSizeAuthor
#5 postgres_case_sesitivity-3361618-5.patch809 byteschi

Comments

Chi created an issue. See original summary.

chi’s picture

Issue summary: View changes
chi’s picture

Issue summary: View changes
chi’s picture

Issue summary: View changes
chi’s picture

StatusFileSize
new809 bytes

The patch used for testing.

steinmb’s picture

Issue tags: +Performance

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

steinmb’s picture

Linking to the performance metrics support we are in the process adding to core. I think this would be very interesting trying to run this type of test though this.

chi’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.