Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fVOep-0001Ms-PI for pgsql-general@arkaria.postgresql.org; Tue, 19 Jun 2018 21:59:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fVOen-0002dR-Oa for pgsql-general@arkaria.postgresql.org; Tue, 19 Jun 2018 21:59:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fVOen-0002dH-Eh for pgsql-general@lists.postgresql.org; Tue, 19 Jun 2018 21:59:21 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fVOek-0006Fy-Gt for pgsql-general@lists.postgresql.org; Tue, 19 Jun 2018 21:59:20 +0000 Received: by mail-pf0-x234.google.com with SMTP id h12-v6so509341pfk.11 for ; Tue, 19 Jun 2018 14:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=zn6azqCzQcf6Gro3unWkCh+JkYnrCkVrxt+v9i75EpI=; b=MSjgPp362PI3SD4n34PJDffc1Yatpv520HTmI0zY8t9gLVl/WLqmxyBDai+9+K72TE Ddyuwk1UMdAIxWtu1TAQ8jZxhDMiVOsBESPMqaiLcCWmuKR+7B/gXIQchMGmfFc01Mzf mEVsfPT9YJ740j6Xz88Xz7/Ay9zUOzJ7iQjyWTonjRMF39a1wZkkLKHgCfesxMSRNi4H 9lD423oNixPu3axg/ZNCdFeuEehK61fcPY0eo4k9lX4AnLrYrMnXP3QR6NPBe0HkJz6k GQT/KIJvLHBrXpUn/zT9hEpStLlm+KHJaTJGL5R+Nkc250kBZd2w26xROmWMVInX6DdC c0lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=zn6azqCzQcf6Gro3unWkCh+JkYnrCkVrxt+v9i75EpI=; b=Z+zQat43cfnswtb4fqWNmnh6Ge6+7KAmzBqJWfeL1Y28CQ4Hne7Y/khRJllBFCkAzu 1PtYZpSse0WOBBiZxlVUTHykRc72/cSHS3qdbF7ormPWCM386/XjBhl9VO3frnyDYWji N4gcHBAf9MfvY2a70/R/kdqtfgf8V9IGTU0DBpi4fOmMBOGr9vGHkNd0cMBKrN05s3MX +Wdbe4SVYomCorIjmydM9BiZouroRxYWkc+PYzCvmT7g9/gZ7drCm6P4Jprs9Hko7kqN TSL0ur5WI9S+aqJCkasPa4Am96EAVp14e8elMbofyruQDp3C+cyH0LtpgxUgdwtnpSuX dTtg== X-Gm-Message-State: APt69E0ummn4ZLvLbxENNYLtDgYO2B1rsLV8ZSWrS01WSQM5PkjKZ3Vi r9vqMVYvi9bzci5xEWzxJKVGNs+6 X-Google-Smtp-Source: ADUXVKJbLO7TExUqNG+3+jouDZ4SECUMBETVtMXV0BWtN7mehfwEyIdgpFEUpri9zSQIhL93ZwzQUQ== X-Received: by 2002:a65:640d:: with SMTP id a13-v6mr16657927pgv.154.1529445555768; Tue, 19 Jun 2018 14:59:15 -0700 (PDT) Received: from tim-desktop (2001-44b8-31f2-bb00-38e2-d080-a52d-395a.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:38e2:d080:a52d:395a]) by smtp.gmail.com with ESMTPSA id q24-v6sm774981pfh.26.2018.06.19.14.59.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Jun 2018 14:59:14 -0700 (PDT) References: User-agent: mu4e 0.9.18; emacs 26.1 From: Tim Cross To: Ravi Krishna Cc: PG mailing List Subject: Re: Load data from a csv file without using COPY In-reply-to: Date: Wed, 20 Jun 2018 07:59:10 +1000 Message-ID: <87602esaj5.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ravi Krishna writes: > In order to test a real life scenario (and use it for benchmarking) I want to load large number of data from csv files. > The requirement is that the load should happen like an application writing to the database ( that is, no COPY command). > Is there a tool which can do the job. Basically parse the csv file and insert it to the database row by row. > Not clear what you mean by 'real world scenario', but you could possibly use PG's foreign table support and define a csv file as a foreign table and then have scripts which read from there and do whatever insert/update etc you need. However, this has a high level of 'fakery' going on and probably not testing what you really want. There are lots of ways that applications write to the database - different drivers (e.g. jdbc, odbc, pg etc), different commit and transaction strategies and even different ways to handle things like an update or insert process. You can even use streams and copy from an application. To get 'real world' equivalence, you really need to use the same interface as the application you are comparing. Most languages have support for processing CSV files, so you may be better off writing a small 'wrapper' app which uses the same drivers and assuming your database connectivity has been abstracted into some sort of module/library/class, use the same interface to write to the database that the application uses. Tim -- Tim Cross