Develop applications with Spanner Omni using supported Spanner features. While many capabilities are shared with Spanner, Spanner Omni has differences in client libraries, the command-line interface (CLI), and console functionality.
Supported Spanner development capabilities include:
Features such as change streams and full-text search.
Key differences
While much of the Spanner development experience applies, the following areas differ in Spanner Omni:
Supported client libraries: Spanner Omni supports the Java, Go, and Python client libraries.
Command-line interface (CLI): The Spanner Omni CLI is a dedicated tool that is distinct from the Google Cloud CLI. While it shares a similar syntax, you don't need to provide the
--instanceflag when running commands.Console limitations: The Spanner Omni console is read-only, so you can't use it to modify deployments or databases.
The following Spanner features and best practices apply to Spanner Omni.
Best practices and use cases
Follow these best practices and use cases to design and optimize your applications for Spanner Omni.
Spanner as a gaming database: Use Spanner's scalability and consistency for gaming backends.
SQL best practices: Optimize your queries for performance and efficiency. Most concepts apply to Spanner Omni. Because Spanner Omni doesn't support tiered storage, concepts such as timestamp predicate pushdown might not fully apply. Also, Spanner Omni doesn't have query plan visualization capabilities.
Language frameworks
Integrate Spanner Omni with popular language frameworks:
Hibernate ORM
Use Hibernate Object-Relational Mapping (ORM) to map your Java objects to Spanner Omni tables. For more information, see the following:
Integrate with Hibernate ORM (PostgreSQL) in the Spanner documentation.
Write a Hibernate app that connects to Spanner in the Spanner documentation.
GORM
Integrate Spanner Omni with GORM, an object-relational mapping (ORM) tool for the Go programming language. To use the object-relational mapping capabilities of GORM in your Go applications. For more information, see the following:
Integrate with GORM (GoogleSQL) in the Spanner documentation.
Integrate with GORM (PostgreSQL) in the Spanner documentation.
Transactions and concurrency
Spanner Omni supports the following transaction management features:
Transactions overview: Learn about read-write and read-only transactions.
Timestamp bounds: Control the staleness of your reads. For Spanner Omni, you can configure version retention period (
version_retention_period) up to 30 days. In Spanner, you can configure this to up to one week.Understand commit timestamps in GoogleSQL databases and in PostgreSQL databases.
TrueTime and external consistency: Understand how Spanner maintains consistency across the deployment.
Isolation levels
Understand the different isolation levels that Spanner Omni supports to ensure data consistency.
Optimization
Use these techniques to optimize your transaction performance and throughput.
Locking
Learn how to use explicit locking to manage concurrent access to your data.
Data access and modification
Access and modify your data using standard Spanner methods, including the client libraries, CLI, and DML.
To learn how client libraries manage sessions, see Sessions. While the underlying session concepts apply to Spanner Omni, it supports multiplexed sessions only.
Reading data
Read data from Spanner Omni using various methods, including stale reads and directed reads.
Modifying data
Modify your data using DML, mutations, or the CLI.
Data types
Spanner Omni supports the following data types to represent your application's data:
Work with arrays in GoogleSQL and in PostgreSQL.
Development and testing
Configure your development environment and application behavior to ensure reliable performance and error handling.
Stream out data changes
Spanner change streams track database changes like inserts, updates, and deletes in near real-time. Managed using DDL, they capture details like primary keys and commit timestamps for entire databases or specific tables. While functionality is nearly identical between Spanner and Spanner Omni, Dataflow is not supported in Spanner Omni.
To learn more, see:
Change streams overview: Learn what change streams do and how they work.
Create and manage change streams: Learn how to use DDL to create, modify, and delete change streams.
Full-text search
Use Spanner full-text search (FTS) to search tables for words, phrases, or numbers. FTS reads the latest committed data.
Key features of FTS include:
- Automatic spelling correction.
- Language detection, including for Chinese, Japanese, and Korean.
To use FTS, create search indexes on the columns you want to search. Spanner breaks down data in these columns into individual words. It updates the index instantly when new data is added.
FTS searches offer advanced capabilities beyond standard text matching, such as:
- Searching for exact numbers and number ranges.
- Finding parts of words (n-grams) for names and misspellings.
- Searching for similar-sounding words (Soundex).
- Ignoring common words.
FTS functionality is consistent between Spanner and Spanner Omni.
Full-text differences in Spanner
Spanner supports the core FTS functionality that's in Spanner with the following differences:
Enhanced query mode isn't supported in Spanner Omni.
An instance in Spanner is equivalent to a deployment in Spanner Omni.