Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

275
Vistas
Sync engine without timezone or not in PostgreSQL?

First, I have read a lot about date types in Postgres using timezone or not. It seems that managing dates (timestamps) with timezone is the best to do in 99% of cases.

Currently I have built a sync engine using a Rails app set to UTC time by default (very important) and MariaDB managing dates (so UTC dates are written in the database but without seeing anything except the date: 2017-04-19 17:45:09). The devices that syncs to the server engine use local SQLite database with dates in UTC too. So for the same document, I can see the same date for a created_at field in the SQLite field and in the MariaDB field. It's working well.

Note that users never have to set a custom timezone in the server app and in the device apps. I want all UTC.

As I plan to migrate to PostgreSQL for many reasons, I'm quite sure I need to use Timestamp without timezone too, but I have some doubts after all readings.

What are your suggestions about this use case ?

EDIT:

So I made 3 tests using pgloader:

Test1: MariaDB => PostgreSQL using computer default timezone

enter image description here

Dates are the same but as you can see, sometimes there is +01, sometimes +02 ???

Test2: MariaDB => PostgreSQL using timezone after setting timezone to UTC in Postgres

enter image description here

Here there is +00, logical for UTC, but my dates were changed.

Test3: MariaDB => PostgreSQL using timestamp WITHOUT timezone

enter image description here

All the same there.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

"With Timezone" simply tells postgres to convert from local time to UTC before storing the timestamp, and to convert back to local time when querying. The underlying data is stored in UTC and no timezone information is stored in the actual data, it's simply a flag the DB uses to determine how to convert the data for human use.

If your client connection is setting the PG timezone to UTC upon DB connection, there will be pretty much no difference. Conventional wisdom says to always use timestamps with timezone, as it'll make queries in other systems (postgresql client) a lot more flexible and easy to use in the future.

over 4 years ago · Santiago Trujillo Denunciar

0

try with one of these in your config file

 SET timezone= 'UTC' 
 SET client_timezone TO '+00:00'

my full settings were:

LOAD DATABASE
     FROM   mysql://usr@localhost/kk
     INTO   postgresql://usr:pwd@localhost/kk
     WITH include drop,
         create tables,
         create indexes,
         reset sequences,
         workers = 8, concurrency = 1,
         multiple readers per thread, rows per range = 50000
     SET PostgreSQL PARAMETERS
        maintenance_work_mem to '512MB',
        work_mem to '64MB',
        timezone to  'UTC'
     SET MySQL PARAMETERS
        net_read_timeout = '220',
        net_write_timeout = '220'
     SET timezone= 'UTC' 
     SET client_timezone TO '+00:00'
     ALTER SCHEMA 'kk' RENAME TO 'public'
;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda