Back to Yugabyte Db

SQL features

docs/content/v2.20/explore/ysql-language-features/_index.md

2026.1.0.0-b253.5 KB
Original Source

YugabyteDB's YSQL API reuses a fork of the query layer of PostgreSQL as its starting point and runs on top of YugabyteDB's distributed storage layer called DocDB. This architecture allows YSQL to support most PostgreSQL features, such as data types, queries, expressions, operators and functions, stored procedures, triggers, extensions, and so on, all of which are expected to work identically on both database systems.

{{< tip title="Tip" >}} A large portion of the documentation and examples written for PostgreSQL would work against YSQL.

{{< /tip >}}

The following diagram shows how YugabyteDB reuses the PostgreSQL query layer, specifically the components that receive the query (postman), the query parser, rewriter, and analyzer, as well as components responsible for planning and executing the query. Some of these components have been modified to perform efficiently in a distributed SQL database.

SQL features in YSQL

The following table lists the most important YSQL features which you would find familiar if you have worked with PostgreSQL.

YSQL FeatureDescription
Schemas and TablesSQL shell with ysqlsh, users, databases, tables, and schemas
Data TypesString, numeric, temporal types, SERIAL pseudo type, ENUM, arrays, composite types
DDL StatementsData definition language
Data ManipulationINSERT, UPDATE, DELETE, INSERT ... ON CONFLICT, and RETURNING clauses
Queries and JoinsQueries, joins, FROM, GROUP BY, HAVING clauses, common table expressions, recursive queries
Expressions and OperatorsBasic operators and boolean, numeric, date expressions
IndexesSupport for indexes and constraints
Stored ProceduresSupport for stored procedures
TriggersTriggers (on data modification) and event triggers (on schema changes)
ExtensionsSupport for PostgreSQL extensions

Advanced features in YSQL

The following table lists the advanced features in YSQL.

YSQL FeatureDescription
CursorsDeclaration of cursors in YSQL
Table PartitioningList, range, and hash partitioning of tables
ViewsViews and updatable views
SavepointsSavepoints in YSQL
CollationsCollations in YSQL
Foreign data wrappersForeign data wrappers in YSQL

Going beyond SQL

Because YugabyteDB is a distributed SQL database, YSQL has a number of features that are not present in PostgreSQL, as summarized in the following table.

YSQL FeatureDescription
Data distribution with HASHEnables the use of HASH sort order, in addition to ASC and DESC for indexes
TablespacesEnables pinning of data in tables and table partitions to different geographic locations
Follower ReadsEnables more read IOPS with low latencies in YugabyteDB clusters