Postgres forcing cases case-insensitivity causes serious performance degradation

Created on 20 May 2023, over 1 year ago
Updated 2 November 2023, about 1 year ago

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.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
PostgreSQL driver 

Last updated about 3 hours ago

No maintainer
Created by

🇷🇺Russia Chi

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024