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 1tprIp-00DKlV-Mc for pgsql-general@arkaria.postgresql.org; Wed, 05 Mar 2025 16:08:59 +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 1tprIn-00FGoX-Go for pgsql-general@arkaria.postgresql.org; Wed, 05 Mar 2025 16:08:57 +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 1tprIn-00FGoO-4j for pgsql-general@lists.postgresql.org; Wed, 05 Mar 2025 16:08:57 +0000 Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tprIj-001893-1D for pgsql-general@lists.postgresql.org; Wed, 05 Mar 2025 16:08:56 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id AC52C11400B2; Wed, 5 Mar 2025 11:08:52 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Wed, 05 Mar 2025 11:08:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1741190932; x=1741277332; bh=a+Ni3LB3kGjhBLMj8yew7ur6cAX7nWt9QMAlLZb7j2Q=; b= QovB/2Y0fUVfzXNiRgDtfCs51h7KHYbHN031D/7bLsSVHO45CfngIWKhS3a9CYdq a12dr/PfbbsIurCUkUMDEfsUlBJQXnWRKbaXqloO7jJrTC0+3HbM+lpfIFQNeGgP ifUtv7+CS9TN82sZDTxmjDH01XoqNX4YoE+gJ4ld9WCgBDCq9X2TSdFxYuraGKyA qI7AwZjXu6DgsgwKaUDZF9aHA/+Jd1qgBzxplOgfXcJwz+vbb5rZFtpEt0+07JW3 3J62/JEnwo3IjUKtVk4pVN5PhvFJJunKuB9XsfxVUmUwTfhW2U8OkLQR37NSrLYH ruFPI4ZRhndjPLE1lY/Ifw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1741190932; x= 1741277332; bh=a+Ni3LB3kGjhBLMj8yew7ur6cAX7nWt9QMAlLZb7j2Q=; b=v AmgqP5VjFuktWUod8lBXZ6MB8Js40cjE5kkhuj6TcfF6qeEYo81BWdOxrRnpqUzX PtexZxppKqwyTAukHOAMFF7+JZpB39lmp2CltK2QNtGesIpEr8P20JxLIlo+pGuj ixZu8WBPc2fj74ndazzzfQvbSxrCsFcztYpxD8yW7TuvCTJXe29R2hoo9CgqWiYI dwESnc02dXZazZP9JOG1UokuGXkJQ5z3rDm6NyPMKLjJKRPwnpqa1rQlr8tTNMVe McFN+YZgLhpFZ9pc70M+IwEK64i0/M1T44GINl0ZvN3lbtmmA/MOmmJo6QsRogRu 5UHKXSmEemWNZqovPgDag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdehvdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddt vdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvh gvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepfeegfeeiuedtgffg teeggfehkeejheetieeliefgteeikeejvdeiveeigfehvedtnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhes rghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepshhnrddufeeiudesghhmrghilhdrtghomhdprhgtphhtthhopehl rghurhgvnhiirdgrlhgsvgestgihsggvrhhtvggtrdgrthdprhgtphhtthhopehpghhsqh hlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 5 Mar 2025 11:08:51 -0500 (EST) Message-ID: <6d7e1022-6404-4dab-8467-8d1f6e8b63cb@aklaver.com> Date: Wed, 5 Mar 2025 08:08:51 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Quesion about querying distributed databases To: me nefcanto , Laurenz Albe Cc: pgsql-general@lists.postgresql.org References: <099b49ebae94e23f19afdad3f8c9c6e702a3a2d5.camel@cybertec.at> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/5/25 04:15, me nefcanto wrote: > Dear Laurenz, the point is that I think if we put all databases into one > database, then we have blocked our growth in the future. How? > A monolith database can be scaled only vertically. We have had huge > headaches in the past with SQL Server on Windows and a single database. > But when you divide bounded contexts into different databases, then you > have the chance to deploy each database on a separate physical machine. > That means a lot in terms of performance. Please correct me if I am wrong. And you add the complexity of talking across machines, as well as maintaining separate machines. > > Let's put this physical restriction on ourselves that we have different > databases. What options do we have? One option that comes to my mind, is > to store the ID of the categories in the Products table. This means that > I don't need FDW anymore. And databases can be on separate machines. I > first query the categories database first, get the category IDs, and > then add a where clause to limit the product search. That could be an > option. Array data type in Postgres is something that I think other > RDBMSs do not have. Will that work? And how about attributes? Because > attributes are more than a single ID. I should store the attribute key, > alongside its value. It's a key-value pair. What can I do for that? You seem to be going out of the way to make your life more complicated. The only way you are going to find an answer is set up test cases and experiment. My bet is a single server with a single database and multiple schemas is where you end up, after all that is where you are starting from. > > Thank you for sharing your time. I really appreciate it. > Saeed > > > > > > On Wed, Mar 5, 2025 at 3:18 PM Laurenz Albe > wrote: > > On Wed, 2025-03-05 at 14:18 +0330, me nefcanto wrote: > > That means a solid monolith database. We lose many goodies with that. > > As a real-world example, right now we can import a single database > > from the production to the development to test and troubleshoot data. > > Well, can't you import a single schema then? > > > What if we host all databases on the same server and use FDW. What > > happens in that case? Does it return 100 thousand records and join > > in the memory? > > It will do just the same thing.  The performance could be better > because of the reduced latency. > > > Because in SQL Server, when you perform a cross-database query > > (not cross-server) the performance is extremely good, proving that > > it does not return 100 thousand ItemId from Taxonomy.ItemCategories > > to join with ProductId. > > > > Is that the same case with Postgres too, If databases are located > > on one server? > > No, you cannot perform cross-database queries without a foreign > data wrapper.  I don't see a reason why the statement shouldn't > perform as well as in SQL Server if you use schemas instead of > databases. > > Yours, > Laurenz Albe > -- Adrian Klaver adrian.klaver@aklaver.com