Limits and differences from Npgsql
This page lists what the .NET client does not do yet, how it differs from Npgsql (the usual PostgreSQL driver for .NET), and when you are better served by Npgsql talking to RasterizedDB's PostgreSQL listener instead. Read it before choosing a driver for a new application.
Release status
RasterizedDb.Data,RasterizedDb.EntityFrameworkCoreandRasterizedDb.Messagingare on NuGet at 1.1.0, released with server 1.1.0; see Getting started.RasterizedDb.Messaging, the message broker client, is pre-production: the broker protocol it speaks is not frozen. See Messaging.
Against an older server
The driver is written against server 1.1.0, where everything on these pages works. Against a 1.0.1 server, three features degrade:
| feature | against 1.0.1 |
|---|---|
| Column names in the binary result format | Not available: GetName answers ?column? and reading by name fails. Read by position, or use the text format (the default). |
Stopping a binary-format statement (CancellationToken, Cancel()) | Not possible: a cancelled token closes the connection instead, and whether the statement ran is unknown. Text-format statements are still stopped. |
Role on a trust connection | Refused when the connection opens. |
What the driver does not do
| missing | instead |
|---|---|
| Streaming results | The whole answer to a statement is held in memory before the first row is read, and must fit Max Message Size (8 MiB by default). Page through large results with LIMIT and a key range, or raise Max Message Size. |
| Server-side prepared statements | Prepare() only caches the driver's scan of the statement text. In the binary format the server reuses its parse for a repeated statement text on its own. |
COPY | connection.BulkInsertAsync loads rows as multi-row INSERTs; see Bulk inserts. For COPY itself, use Npgsql over the PostgreSQL listener. |
LISTEN / NOTIFY | Use Npgsql over the PostgreSQL listener. |
Output, return-value and input/output parameters; CommandType.StoredProcedure | Call functions with SELECT f(…). |
TransactionScope and distributed transactions | Use BeginTransactionAsync on a connection. |
| A dependency injection extension | Register a RasterizedDbDataSource singleton yourself; see Registering with dependency injection. |
| Several hosts in one connection string, or failover between them | One server per connection string. |
| Certificate revocation checks | Pin the certificate (Trust=Pinned) when that matters. |
| A plain, unencrypted TCP mode | Use a unix socket on the same machine. |
| Multi-dimensional arrays | Select them as col::text. |
The EF Core provider's own gaps are listed in EF Core.
Behaviour to plan for
- Statements stop at 30 seconds by default. That is the server's native statement limit (
--rdb-request-timeout). Raise it on the server, or withSET statement_timeoutinside a transaction, together with the driver'sCommand Timeout; see Timeouts. - Connections quiet for 30 seconds are closed by the server. The pool keeps idle connections alive and swaps quiet ones before use, so outside a transaction you do not see this. A transaction quiet for 30 seconds is lost, whatever the server's request timeout is set to; see Lost transactions.
- Nothing is retried for you after a connection failure. A statement whose connection fails throws, because whether it ran is unknown. Only serialization failures and deadlocks are safe to retry, which
ExecuteInTransactionAsyncand the EF Core provider'sEnableRetryOnFailuredo. - The binary format runs one statement per command. Several statements need the text format (the default).
- Commands on a data source's shared connection cannot use transactions, temporary tables or session settings.
SERIALIZABLEbehaves asREPEATABLE READon the server, without write-skew detection.
Differences from Npgsql
Code written for Npgsql mostly carries over at the ADO.NET level (DbConnection, DbCommand, DbDataReader, DbDataSource, DbBatch), but check these:
| area | RasterizedDb.Data |
|---|---|
| Port | 61170 (the native listener), not 5432. |
| TLS keywords | Trust, Root Certificate, Certificate Fingerprint, Client Certificate, Client Key. There is no SSL Mode: TCP is always TLS 1.3. |
| Unknown keywords | An error. Npgsql-only keywords such as SSL Mode or Search Path must be removed. Application Name is accepted and ignored. |
| Result format | Two formats, Text (the default, with column names and several statements per command) and Binary (one statement, faster). See The two result formats. |
| Parameters | @name or $1…$n, not mixed in one statement. $n refers to the parameter's position in the collection, whatever its name. Values are written into the statement as literals; there is no NpgsqlDbType, and DbType matters only for a few date and time choices. |
DateTime parameters | Any Kind is accepted. Utc and Local values are sent as instants, Unspecified ones as wall-clock times with no zone; see Dates and times. Review code that relies on a driver refusing a DateTime of the wrong Kind. |
| Type plug-ins | No NodaTime, spatial, range or other type plug-ins. |
| Multiplexing | Commands made by dataSource.CreateCommand share one connection with many statements in flight, without transactions. |
| Errors | RasterizedDbException with SqlState, IsTransient, Kind and CommitOutcomeUnknown in place of PostgresException. |
| Extras | Typed administration calls (connection.Admin), the key/value cache (connection.Kv), and a migrator (RasterizedDbMigrator). |
When to use Npgsql instead
RasterizedDB also serves the PostgreSQL wire protocol, so Npgsql (and the tools and libraries built on it) can connect to it. Start the server with the PostgreSQL listener, alone or beside the native one:
export RASTERIZEDDB_PG_PASSWORD='change-me-now'
rasterizeddb --location ./rdb-data --protocol both --pg-user app--protocol is rastcp (native only, the default), pgwire (PostgreSQL only) or both. The PostgreSQL listener uses --pg-addr (127.0.0.1) and --pg-port (5432), and asks for a SCRAM-SHA-256 password unless --pg-auth says otherwise. Under both the two listeners share one role catalogue, so the same role logs in on either. Then connect with an ordinary Npgsql connection string:
Host=127.0.0.1;Port=5432;Username=app;Password=change-me-now;Database=postgresPrefer Npgsql over the PostgreSQL listener when:
- you must run against a 1.0.1 or older server, where some of this driver's features degrade (see Against an older server);
- you need
COPY,LISTEN/NOTIFY, or server-side prepared statements with bound parameters (the extended query protocol); - your statements routinely run longer than 30 seconds: the native listener's statement limit does not apply to the PostgreSQL listener;
- you depend on libraries or tools that require Npgsql or a PostgreSQL connection.
Prefer RasterizedDb.Data when:
- you want the native path: typed binary results and a server that reuses its parse for repeated statements;
- you use the key/value cache or the administration calls from .NET;
- you run many small independent statements and want them multiplexed on one connection.
How closely the PostgreSQL listener follows PostgreSQL is described in PostgreSQL compatibility, and how to connect to either listener in Connecting.