Consistency and Data Type Behavior
Learn about data type behavior and explore the details of indexing in PostgreSQL.
Data type behavior
A key aspect of PostgreSQL data types lies in their behavior. Comparable to an object-oriented system, PostgreSQL implements functions and operator polymorphism, allowing for the dispatching of code at runtime depending on the types of arguments.
The data type of a literal
If we take a closer look at a very simple SQL query, we can see lots happening under the hood:
select code from drivers where driverid = 1;
In this query, the expression driverid = 1 uses the = operator between a column name and a literal value. PostgreSQL knows from its catalogs that the driverid column is a bigint and parses the literal 1 as an integer. We can check that with the following query:
select pg_typeof(driverid), pg_typeof(1) from drivers limit 1;
It would give ...
Ask