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.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | postgres_case_sesitivity-3361618-5.patch | 809 bytes | chi |
Comments
Comment #2
chi commentedComment #3
chi commentedComment #4
chi commentedComment #5
chi commentedThe patch used for testing.
Comment #6
steinmb commentedComment #8
steinmb commentedLinking 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.
Comment #9
chi commentedPossible solution
https://stackoverflow.com/questions/18807276/how-to-make-my-postgresql-d...