Обсуждение: Insert more then one row
Hi,
I'm using Pgsql 8.1 in my project and I have to insert more than one rows with one sql query as the insert commmand slows a lot the server and comsumes too much resources. I have read some older mails about this and most of them recommended to use COPY command but the thing is I don't have a chance to create a file. I have a php form which takes data and then execute some queries after the submit. I will have probably 100 rows maximum (just a guess). It wont slow down a lot, but I want to find and use a better alternative than to use a for statement to insert datas.
In some of the mails someone had talked about to use the copy's stdout command. But I can't honestly say that I understood clearly how to use it.
I don't want to create a file with php and then populate and then use the copy command by that as it will be more problematic. So what do you suggest? Can I use the COPY command without pointing a file? Or can I point a string variable to use it as source while the delimeter is something else than the tab character (the | character perhaps). Or can I point a string array simply? (When i say point i mean to use it as datasource. Sorry for my bad english)
Thank you for your time
Roy Simkes
Express yourself instantly with Windows Live Messenger
I'm using Pgsql 8.1 in my project and I have to insert more than one rows with one sql query as the insert commmand slows a lot the server and comsumes too much resources. I have read some older mails about this and most of them recommended to use COPY command but the thing is I don't have a chance to create a file. I have a php form which takes data and then execute some queries after the submit. I will have probably 100 rows maximum (just a guess). It wont slow down a lot, but I want to find and use a better alternative than to use a for statement to insert datas.
In some of the mails someone had talked about to use the copy's stdout command. But I can't honestly say that I understood clearly how to use it.
I don't want to create a file with php and then populate and then use the copy command by that as it will be more problematic. So what do you suggest? Can I use the COPY command without pointing a file? Or can I point a string variable to use it as source while the delimeter is something else than the tab character (the | character perhaps). Or can I point a string array simply? (When i say point i mean to use it as datasource. Sorry for my bad english)
Thank you for your time
Roy Simkes
Express yourself instantly with Windows Live Messenger
> Hi,I'm using Pgsql 8.1 in my project and I have to insert more than one rows with one sql query > as the insert commmand slows a lot the server and comsumes too much resources. I have read some > older mails about this and most of them recommended to use COPY command but the thing is I don't > have a chance to create a file. I have a php form which takes data and then execute some queries > after the submit. I will have probably 100 rows maximum (just a guess). It wont slow down a lot, > but I want to find and use a better alternative than to use a for statement to insert datas.In > some of the mails someone had talked about to use the copy's stdout command. But I can't > honestly say that I understood clearly how to use it. I don't want to create a file with php and > then populate and then use the copy command by that as it will be more problematic. So what do > you suggest? Can I use the COPY command without pointing a file? Or can I point a string > variable to use it as source while the delimeter is something else than the tab character (the | > character perhaps). Or can I point a string array simply? (When i say point i mean to use it as > datasource. Sorry for my bad english)Thank you for your timeRoy Simkes It would probably be easier to improve preformance by preforming multiple inserts inside a single transaction. This should help with preformance in the near term and give you time to learn the "ins and outs" of pipes and standard out. Regards, Richard Broersma Jr.