NEW RasterizedDB 1.1.0 is out: sharding and the gateway, the message broker, roles and row-level security, compression, .NET on NuGet, and the enterprise edition. What's new ›
DOCS / C# / .NET CLIENT / LIMITS AND DIFFERENCES FROM NPGSQL

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.EntityFrameworkCore and RasterizedDb.Messaging are 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:

featureagainst 1.0.1
Column names in the binary result formatNot 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 connectionRefused when the connection opens.

What the driver does not do

missinginstead
Streaming resultsThe 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 statementsPrepare() 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.
COPYconnection.BulkInsertAsync loads rows as multi-row INSERTs; see Bulk inserts. For COPY itself, use Npgsql over the PostgreSQL listener.
LISTEN / NOTIFYUse Npgsql over the PostgreSQL listener.
Output, return-value and input/output parameters; CommandType.StoredProcedureCall functions with SELECT f(…).
TransactionScope and distributed transactionsUse BeginTransactionAsync on a connection.
A dependency injection extensionRegister a RasterizedDbDataSource singleton yourself; see Registering with dependency injection.
Several hosts in one connection string, or failover between themOne server per connection string.
Certificate revocation checksPin the certificate (Trust=Pinned) when that matters.
A plain, unencrypted TCP modeUse a unix socket on the same machine.
Multi-dimensional arraysSelect 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 with SET statement_timeout inside a transaction, together with the driver's Command 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 ExecuteInTransactionAsync and the EF Core provider's EnableRetryOnFailure do.
  • 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.
  • SERIALIZABLE behaves as REPEATABLE READ on 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:

areaRasterizedDb.Data
Port61170 (the native listener), not 5432.
TLS keywordsTrust, Root Certificate, Certificate Fingerprint, Client Certificate, Client Key. There is no SSL Mode: TCP is always TLS 1.3.
Unknown keywordsAn error. Npgsql-only keywords such as SSL Mode or Search Path must be removed. Application Name is accepted and ignored.
Result formatTwo 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 parametersAny 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-insNo NodaTime, spatial, range or other type plug-ins.
MultiplexingCommands made by dataSource.CreateCommand share one connection with many statements in flight, without transactions.
ErrorsRasterizedDbException with SqlState, IsTransient, Kind and CommitOutcomeUnknown in place of PostgresException.
ExtrasTyped 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:

sh
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:

text
Host=127.0.0.1;Port=5432;Username=app;Password=change-me-now;Database=postgres

Prefer 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.

✓ page rendered in 129 µs axum + tera + htmx · no other javascript