Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

367
Visualizações
In Postgres, running ANALYZE changes behaviour of ILIKE clause with COLLATE

We are migrating an application from SQL Server to Postgres and attempting to emulate various aspects of the case insensitivity of SQL Server. We have created a non-deterministic collation to support case-insensitive matching of foreign keys and equality comparisons.

But we are seeing some weird behaviour when using ILIKE which we can't explain, and would appreciate some assistance.

To see the behaviour, run the following on a fresh database:

CREATE COLLATION IF NOT EXISTS public.ci (provider = icu, locale = 'und-u-ks-level2', deterministic = false);

DROP TABLE IF EXISTS sort_test;

CREATE TABLE sort_test (a text COLLATE public.ci);

INSERT INTO sort_test SELECT md5(n::text) FROM generate_series(1, 10000) n;

-- Removing the following line fixes the issue
ANALYZE sort_test;

-- This line throws "nondeterministic collations are not supported for ILIKE"
SELECT * FROM sort_test WHERE a ILIKE 'c4ca4238a0%' COLLATE "und-x-icu";

Why does running the ANALYZE statement break the ILIKE statement?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

That behavior is a PostgreSQL bug.

The reason why it works without the ANALYZE is that the error is thrown when applying the operator to the “histogram bounds” in the statistics. Before ANALYZE there are no statistics, so no error is thrown.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda