Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!