Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uorfz-00Bqjm-GA for pgsql-general@arkaria.postgresql.org; Wed, 20 Aug 2025 22:53:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uorfx-00Bvja-I6 for pgsql-general@arkaria.postgresql.org; Wed, 20 Aug 2025 22:53:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uorfx-00BvjR-3q for pgsql-general@lists.postgresql.org; Wed, 20 Aug 2025 22:53:01 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uorfv-000zMi-04 for pgsql-general@lists.postgresql.org; Wed, 20 Aug 2025 22:53:01 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-323266b2368so278963a91.0 for ; Wed, 20 Aug 2025 15:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755730376; x=1756335176; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1zV5wYHlVIRD41VoUblD4MqR2rg/tTGQ3B3/ddlx72k=; b=bgW4ED3lZKNUIRziwT+FLwyEKPWNLoES0gogxwGfrY/FOFfrc2p2oM5gJGwZCf3xM6 Q911esiF5hmu73Squnz+IoG6mFwrqYXX0l18lJ5GsJ6OCTCUd0qTpw6NQIoC2kuKq5rl hlOrbZqaeYcF+AqiivK2p3QbSsrOkGgZqrkcr2Uc08R8+OUSLSMOo7+f+GB1b2vEoULT apIwRCcxKcBGEVhIovCOKP0N351vVTq2wuJqN4zTraADT+EA5B3XQtZX8C0M0aaIBjO0 nzW0zmKvTc+vdCD3qoijaQoJ0Y16+0WFkPG0d1M7MJLoB7jrtSm8Kgl6QMGKdIK/R2HM NJ+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755730376; x=1756335176; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1zV5wYHlVIRD41VoUblD4MqR2rg/tTGQ3B3/ddlx72k=; b=qYoci8jUwwMFOG3fh+NzQ/bWZUMMksiLiB7iwk1doWNIXfD3C6bZL2RuapTd1fkWt+ WueKJzgVbh5O07vbjqpI8Ox34+PFb4qA1dchuCXY05iKRcdD7aN75Ucq22HupoXXOrib bgthVVvShW2361cc4FoiqeU3Ut3wMZ+pBMDEC+91PJsB/Fh+7Sy+La79usEg6gCzyHhf kBBFDGlU5IF3t4lAjb6TLCAjx2fZ2gwGEQidjbmb+FMVEjYIjD6rNvn+uBp5QeHNPokV GVn4gsSLUykfT4lrFcR4NLLDRG/Dpfd1qgCI6VfYrxv8U3gvMWxcwWz0Z2ZCi6KTLTPp 9PFQ== X-Gm-Message-State: AOJu0YxEt0bjEYQYvDiG5K4j8nz7ZRMvzKp89QwUZV4DLCtaEE5xVf0F BkiclNRJ4lIjyUALvWyjl0K/5jaEGZV7RiAkGjHVnHY5EXkdGtec55ueRGTDxbXqexiZmzxgO+D FtIhg9sMNm4hhY1y1O5GPVeF2j4/bQE4= X-Gm-Gg: ASbGncvwr0AEjpdG2tkkvs83kPfzkv6ee6uhJ0Hhl09dRHThZcOuRVj6aMmbhUViWk/ sOCB/4te4V0YXYNIhtoAG7jA0PboYPnOPC9RTDwJdiEwtA33bOyjn8znyF6BsvKXn59gFHGirGe xlETieKKMkeIO5W2nsY8VDsQfa6eofh83UbaYNwyvfip+ksncR5HueMGScWfyUN1GzYexcEmDVv wZDLw== X-Google-Smtp-Source: AGHT+IHdYcy/7IkIiqRx7m1NwZvzGkEZghhchOnIZGLITwqAQnq2SDb98szJylipoOzYMXySzZOdNGUiYbtEN8GpjEI= X-Received: by 2002:a17:90b:1293:b0:324:e298:3eba with SMTP id 98e67ed59e1d1-324ed0f15a5mr464676a91.7.1755730376146; Wed, 20 Aug 2025 15:52:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Avinash Vallarapu Date: Wed, 20 Aug 2025 18:52:43 -0400 X-Gm-Features: Ac12FXxAAP_LSr9jXjTO3b429cZ_Kauon-ZmDEkLATSHlcufeqgMBuzaUJnHZYc Message-ID: Subject: Re: MS SQL to Postgres To: KK CHN Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000006442d6063cd3d5b2" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006442d6063cd3d5b2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Krishane, On Wed, Aug 20, 2025 at 1:26=E2=80=AFPM KK CHN wrote: > Hi, > > I am in search of the best practices to migrate from an MS SQL database > server to PostgreSQL 16 > > Existing DB server MSSQL with 6 Million records and 3.5 TB with 424 > Tables running from 2019 onwards. > This is definitely not a problem, I have seen hundreds of migrations with more than 2k Tables and 10TB data from MSSQL 2019. > > Each table has 5 to 16 columns ( basically text, numbers, lat long > coordinates , time stamps, and images/voice file (stored in archive > folders)reference links, etc. ). > This is not a problem either. > > I am in need to port / migrate all this data from this MS SQL server to > Postgres16 . > > 1. What are the best methods and practices folks employ to do this kind o= f > data porting operations? > You could use Open Source migration tools like: pgloader for schema migration (excluding any code objects like procedures or functions). Or you could also use tools like HexaRocket: www.hexarocket.com One more extension you could try is: tds_fdw, using which you could directly query your MSSQL database and load data to PostgreSQL, but be prepared to see some surprises. > 2. what are the tools and techniques to explored / employed for this > Already answered in the previous question. 3. How much time is consumed by employing the right tools, the entire > porting of 6 million records of 3.5 TB size to Postgres 16 takes > While there cannot always be a direct answer, I can talk about the tool: *HexaRocket *for some of such migrations. It took around 12 Hours, but remember, this can be more or even lesser depending on your Infrastructure. 4. Any hurdles or challenges or risks > > Kindly enlighten me with the best practices and reference materials / > links or tutorials to perform these operations successfully. > There are several differences you need to be aware of between MSSQL and PostgreSQL. - Start with the data type mapping to begin with. - If PostGIS is enabled, use types like geometry, geography. Can use text for fallback support. - PostgreSQL supports composite types, arrays at the column level natively, while SQL Server cannot. - SQL Server often auto-generates constraint names, while PostgreSQL typically requires explicit names. - There is a good amount of difference between Clustered Indexes in SQL Server vs PostgreSQL - Spatial Indexes (Geometry/Geography) requires PostGIS extension in PostgreSQL. - Using PostgreSQL's native IDENTITY feature instead of legacy SERIAL/BIGSERIAL, as IDENTITY matches SQL Server's behavior with clear syntax. - In SQL Server, RANGE partitioning is the only natively supported partitioning method. But, during migration, partition boundaries must be carefully adjusted to match PostgreSQL's behavior. - User Defined Table Types of SQL Server are migrated to PostgreSQL as composite types which can encapsulate multiple columns under single type. - There is a much more bigger list for every category, so I will share with you a Slide deck from one of my talks on MSSQL to PostgreSQL. --=20 Regards, Avinash Vallarapu +1-902-221-5976 www.hexarocket.com --0000000000006442d6063cd3d5b2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Krishane,

O= n Wed, Aug 20, 2025 at 1:26=E2=80=AFPM KK CHN <kkchn.in@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
Hi,=C2=A0=

I am in search of the best practices to migrate fro= m an MS SQL database server to PostgreSQL 16

Exist= ing=C2=A0DB server=C2=A0MSSQL with 6 Million records and 3.5 TB=C2=A0 with = 424 Tables running from 2019 onwards.
This is = definitely not a problem, I have seen hundreds of migrations with more than= 2k Tables and 10TB data from MSSQL 2019.

Each table has 5= to 16 columns ( basically text, numbers, lat long coordinates , time stamp= s, and images/voice file (stored in archive folders)reference links, etc.= =C2=A0 ).
This is not a problem either.
=C2= =A0

I am in need to port / migrate all this data from this= MS SQL server to Postgres16 .

1. What are the bes= t methods and practices folks employ to do this kind of data porting operat= ions?=C2=A0=C2=A0
You could use Open Source mi= gration tools like: pgloader for schema migration (excluding any code objec= ts like procedures or functions).
Or you could also use tools lik= e HexaRocket: www.hexarocket.com<= /div>
One more extension you could try is: tds_fdw, using which you cou= ld directly query your MSSQL database and load data to PostgreSQL, but be p= repared to see some surprises.
=C2=A0
2. what are the tools and= techniques to explored / employed for this
= =C2=A0Already answered in the previous question.=C2=A0

=
3. = How much time is consumed by employing the right tools, the entire porting = of 6 million records of 3.5 TB size to Postgres 16 takes=C2=A0
<= /blockquote>
While there cannot always be a direct answer, I can talk a= bout the tool:HexaRocket=C2=A0for some of such migrations.
It took around 12 Hours, but remember, this can be more or even lesser dep= ending on your Infrastructure.

4. Any hurdles or challenge= s or risks=C2=A0

Kindly enlighten me with the best= practices and=C2=A0 reference materials=C2=A0/ links or tutorials to perfo= rm=C2=A0these operations successfully.=C2=A0
T= here are several differences you need to be aware of between MSSQL and Post= greSQL.
  • Start with the data type mapping to begin with.
  • If PostGIS is enabled, use types like geometry, geography. Can use t= ext for fallback support.
  • PostgreSQL supports composite types, arra= ys at the column level natively, while SQL Server cannot.
  • SQL Serve= r often auto-generates constraint names, while PostgreSQL typically require= s explicit
    names.
  • There is a good amount of difference between C= lustered Indexes in SQL Server vs PostgreSQL
  • Spatial Indexes (Geome= try/Geography) requires PostGIS extension in PostgreSQL.
  • Using Post= greSQL's native IDENTITY feature instead of legacy SERIAL/BIGSERIAL, as= IDENTITY matches SQL
    Server's behavior with clear syntax.
  • I= n SQL Server, RANGE partitioning is the only natively supported partitionin= g method. But, during migration, partition boundaries must be carefully adj= usted to match PostgreSQL's behavior.
  • User Defined Table Types = of SQL Server are migrated to PostgreSQL as composite types which can
    en= capsulate multiple columns under single type.
  • There is a much more = bigger list for every category, so I will share with you a Slide deck from = one of my talks on MSSQL to PostgreSQL.


--
Re= gards,
Avinash Vallarapu
+1-902-221-5976
--0000000000006442d6063cd3d5b2--