pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAdding many rows to a table.
2+ messages / 2 participants
[nested] [flat]
* Adding many rows to a table.
@ 2000-05-20 21:53 Stuart Grimshaw <stuart@stubbynet.org.uk>
0 siblings, 1 reply; 2+ messages in thread
From: Stuart Grimshaw @ 2000-05-20 21:53 UTC (permalink / raw)
To: pgsql-sql
I was recently doing some testing into which of two methods of searching a
large block of text was faster. One of the ways I came up with was to
identify keywords in an article and then have a table to cross reference
these keywords back to the article they appear in.
article|keyword
---------------
520 |cheese
520 |bread
521 |pickle
522 |spam
you get the picture.
I wrote a perl program to extract these keywords, with the idea of inserting
them into a database. The first way I tried was to have lots on "insert
into"'s in 1 string, then execute that string. Worked OK until the string
contained too many keywords and the query was too large (this was under
6.5.3)
The docs suggest using "copy to" for inserting lots of data. I created a
string :
COPY TO keywords FROM STDIN USING DELIMITERS ',';
520,cheese
520,bread
521,pickle
522,spam
\.
and then executed it, and got the following error
ERROR: parser: parse error at or near "520"
So my question is, after all that, is that the right way to construct my
string (regardless of language, Perl C/C++ etc)
By the way, I've ditched this idea for now, and just use a common or garden
index on the feild I want to search for the keywords. I just want to be able
to actually do this, you never know when it might come in handy.
---------------------------------------
Stuart Grimshaw |
Schoolsnet LTD | Special
www.schoolsnet.com | Projects
| Developer
stuart@stubbynet.org.uk |
---------------------------------------
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Adding many rows to a table.
@ 2000-05-21 04:54 Tom Lane <tgl@sss.pgh.pa.us>
parent: Stuart Grimshaw <stuart@stubbynet.org.uk>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2000-05-21 04:54 UTC (permalink / raw)
To: Stuart Grimshaw <stuart@stubbynet.org.uk>; +Cc: pgsql-sql
"Stuart Grimshaw" <stuart@stubbynet.org.uk> writes:
> The docs suggest using "copy to" for inserting lots of data. I created a
> string :
> COPY TO keywords FROM STDIN USING DELIMITERS ',';
> 520,cheese
> 520,bread
> 521,pickle
> 522,spam
> \.
> and then executed it, and got the following error
> ERROR: parser: parse error at or near "520"
> So my question is, after all that, is that the right way to construct my
> string (regardless of language, Perl C/C++ etc)
That does work as a psql script. In other client interfaces you might
need to submit the COPY data separately from the initial COPY command.
Hard to say more without knowing exactly what you tried with which
interface ...
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-05-21 04:54 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-05-20 21:53 Adding many rows to a table. Stuart Grimshaw <stuart@stubbynet.org.uk>
2000-05-21 04:54 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox