Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nK58k-00019H-BQ for pgsql-sql@arkaria.postgresql.org; Tue, 15 Feb 2022 21:13:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nK58j-0003h4-6s for pgsql-sql@arkaria.postgresql.org; Tue, 15 Feb 2022 21:13:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nK58i-0003gM-Qb for pgsql-sql@lists.postgresql.org; Tue, 15 Feb 2022 21:13:36 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nK58f-0000SG-Vi for pgsql-sql@lists.postgresql.org; Tue, 15 Feb 2022 21:13:36 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 195so73873pgc.6 for ; Tue, 15 Feb 2022 13:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=P4NyTyjWxKhL3F5HQMQ9x+bxxhtcKpbZQ5o+d9HUGCU=; b=hv/GHE8cxJSPOaHTIwiZPI+d9Pouubr+FF9i6DoAWeDmH/xfPr2m7EzBYTaQ1kPKyJ TDzhzZDrA6eyA/vPpd13zaC0Y3zqiVGlfuKkcsgCA0AikN2Ar7C+YbNEh7DxlQe74s/F E1QihlwGyBhDGeeqGwYh4G+CbLxUTte7EgrkotHmhTjEvxV4Hetbblddo95+mv5VYrJd R4zVr3kX2F3ub5DbhnMhqhWcgKZNS1HZr7bRR4DCjB7jzqgu4uHik4y3pmSnouEWsDfy txTx3/k0O91gU7cr68SRmpJqIcYv8eGq7f7JEQQzqaJ0R6DolLWYk38+tAuVeL0dw1ul wUJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=P4NyTyjWxKhL3F5HQMQ9x+bxxhtcKpbZQ5o+d9HUGCU=; b=uD/n05XDhR/ARx0ZSlaJBTDySNvnmkOkI+tvwT4AHZmlvCvYbsen8ARMhvhm1yVuaL SmnRl4iNXT3CwfZt6BRvmDAabIeJ30HaG/Pw+gTPGk5eqJp06V6pDyuRNlCfgq9fgRMT Wpc9IEgo97M6piW/6Rc9hMw7JH6vj7BaUL9EIvvMciZSUDxLFg7xc6oTAH6EPUcomwMq Umnp1Py04287BwzV6JJ4uT72LfaLYyjfpMKJ2NY6nfKZMVpT8eUskNofvw737Zb40ATf DN+9rMvB/cQY9Q468A6PuH7vNQQ5+ODVF1s7YeZ1ePTjVCl3DXrlsJQRy9xsQNTFVhuj clKg== X-Gm-Message-State: AOAM532M6Rpyy9OebpaIEyiYGjwIseUiKHI0fvlI30mprIY79/Y+W14T Uf60/zC4KepTY7JVzvbT6muXSXyyWg0= X-Google-Smtp-Source: ABdhPJxsLv5Yi6ybYGjrXcauhIx6DyEj5A6EylVDQW2GYLA0oshTCIEa9grhHGCbvezY+QyPVReO+A== X-Received: by 2002:a63:f00b:: with SMTP id k11mr633056pgh.469.1644959611692; Tue, 15 Feb 2022 13:13:31 -0800 (PST) Received: from [10.128.71.194] ([155.98.131.2]) by smtp.gmail.com with ESMTPSA id x12sm3325510pgp.25.2022.02.15.13.13.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Feb 2022 13:13:31 -0800 (PST) Content-Type: multipart/alternative; boundary="------------C9cGgG0ZFLPpUrAcXqf5Z4ba" Message-ID: <9abb8f15-001e-8aa8-d930-fe5af71f829c@gmail.com> Date: Tue, 15 Feb 2022 14:13:30 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: Storing thousands of csv files in postgresql Content-Language: en-CA To: pgsql-sql@lists.postgresql.org References: From: Rob Sargent In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------C9cGgG0ZFLPpUrAcXqf5Z4ba Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > I don't think you need a "federated" postgres network like Citus at > all - I think this solves a different use case. For your design > problem, I think that having a bunch of independent Pg servers would > be fine - as long as you don't need to run searches across CSV tables > stored across different databases (in which case you do need > index/search federation of some kind). > > Regarding Erik Brandsberg's point about XFS, I think this is a useful > alternative approach, if I understand the idea. Instead of storing > your CSV files in Postgres, just store them as CSV files on the file > system. You can still store the schemas in Pg, but each schema would > just point to a file in the file system and you'd manipulate the files > in the filesystem using whatever language is appropriate (I find ruby > to be excellent for managing CSV files). If you need to index those > files to run searches against them, I'd direct your attention to > https://prestodb.io/ which is the core technology that runs Amazon > Athena. This allows you to search CSV files with various schema (among > other data bindings). So you might find that Pg as your schema > storage, XFS (or any modern FS) to store large numbers of CSV files, > and Presto/Athena to index/search those files, along with some CSV > management language (like Ruby or something even higher level) to > manage the data. > > I think if I were dealing with less than 10k CSV files (and therefore > Pg tables), I might use Pg, and if I were dealing with 10k+ files, I'd > start looking at file systems + Presto. But that's a WAG. > > Steve > > I think the add/remove column requirement alone justifies NOT using files.  The CSV approach will temp the system to handle some versioning nonsense. Using tables also provides some protection against the inevitable garbage data in the CSVs. --------------C9cGgG0ZFLPpUrAcXqf5Z4ba Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
I don't think you need a "federated" postgres network like Citus at all - I think this solves a different use case. For your design problem, I think that having a bunch of independent Pg servers would be fine - as long as you don't need to run searches across CSV tables stored across different databases (in which case you do need index/search federation of some kind).

Regarding Erik Brandsberg's point about XFS, I think this is a useful alternative approach, if I understand the idea. Instead of storing your CSV files in Postgres, just store them as CSV files on the file system. You can still store the schemas in Pg, but each schema would just point to a file in the file system and you'd manipulate the files in the filesystem using whatever language is appropriate (I find ruby to be excellent for managing CSV files). If you need to index those files to run searches against them, I'd direct your attention to https://prestodb.io/ which is the core technology that runs Amazon Athena. This allows you to search CSV files with various schema (among other data bindings). So you might find that Pg as your schema storage, XFS (or any modern FS) to store large numbers of CSV files, and Presto/Athena to index/search those files, along with some CSV management language (like Ruby or something even higher level) to manage the data.

I think if I were dealing with less than 10k CSV files (and therefore Pg tables), I might use Pg, and if I were dealing with 10k+ files, I'd start looking at file systems + Presto. But that's a WAG.

Steve

 

I think the add/remove column requirement alone justifies NOT using files.  The CSV approach will temp the system to handle some versioning nonsense. Using tables also provides some protection against the inevitable garbage data in the CSVs.  --------------C9cGgG0ZFLPpUrAcXqf5Z4ba--