(Originariamente parte di this question, ma era un po 'irrilevante, così ho deciso di farne una questione a sé stante.)Operatore ~ <~ in Postgres
Non riesco a trovare quello che l'operatore ~<~
è. Il manuale di Postgres menziona solo ~
e operatori simili here, ma nessun segno di ~<~
.
Quando giocherellare nella console psql, ho scoperto che questi comandi danno gli stessi risultati:
SELECT * FROM test ORDER BY name USING ~<~;
SELECT * FROM test ORDER BY name COLLATE "C";
E questi dà l'ordine inverso:
SELECT * FROM test ORDER BY name USING ~>~;
SELECT * FROM test ORDER BY name COLLATE "C" DESC;
anche alcune informazioni sugli operatori tilde :
\do ~*~
List of operators
Schema | Name | Left arg type | Right arg type | Result type | Description
------------+------+---------------+----------------+-------------+-------------------------
pg_catalog | ~<=~ | character | character | boolean | less than or equal
pg_catalog | ~<=~ | text | text | boolean | less than or equal
pg_catalog | ~<~ | character | character | boolean | less than
pg_catalog | ~<~ | text | text | boolean | less than
pg_catalog | ~>=~ | character | character | boolean | greater than or equal
pg_catalog | ~>=~ | text | text | boolean | greater than or equal
pg_catalog | ~>~ | character | character | boolean | greater than
pg_catalog | ~>~ | text | text | boolean | greater than
pg_catalog | ~~ | bytea | bytea | boolean | matches LIKE expression
pg_catalog | ~~ | character | text | boolean | matches LIKE expression
pg_catalog | ~~ | name | text | boolean | matches LIKE expression
pg_catalog | ~~ | text | text | boolean | matches LIKE expression
(12 rows)
il 3 ° e 4 ° fila è l'operatore che sto cercando, ma il disc la razione è un po 'insufficiente per me.
Questo operatore viene utilizzata da Postgres per la ricerca se si dispone di un indice con opclass. http://www.postgresql.org/docs/9.5/static/indexes-opclass.html –
Crea un indice su 'test (nome text_pattern_ops)' e guarda l'output di 'EXPLAIN' per' nome LIKE 'abc%' ' –