currentTableName character varying := 'job_' || '2011_11';
BEGIN
EXECUTE 'INSERT INTO '|| currentTableName || ' (c, d) VALUES ($1, $2)'
USING NEW.a, NEW.b;
RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
Josh
--
Sent via pgsql-sql mailing list (pgsql-sql
On Tue, Nov 8, 2011 at 11:04 AM, Sylvain Mougenot smouge...@sqli.com wrote:
EXECUTE 'INSERT INTO '|| currentTableName || ' values (NEW.*)';
The quotes in the above line are wrong; you want it like:
EXECUTE 'INSERT INTO '|| currentTableName || ' values ' || (NEW.*);
Josh
--
Sent via pgsql-sql
Josh
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
spaces), and perhaps the ease of
expanding the length constraint in the future.
Josh
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
rows). Most of the dependent tables have ON
DELETE CASCADE. The 'unique_records' table is a temp table I got via
something like: SELECT DISTINCT (other_column) id INTO unique_records
FROM records
Thanks very much!
Josh Leder
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make
Many of the tables do not have indexes on the FK, though a couple of
the biggest ones do. It does seem worth the time to put an index on
each of these tables, considering the few hundred hours I'm already
spending on the DELETE.
I've started the EXPLAIN ANALYZE but it will take a while, no doubt.
.
Of course, you could cook up some script to parse the text returned by
psql to figure out the rowcounts, but that's a much greater pain than
just implementing whatever you're trying to do in a scripting language
using a PostgreSQL database adapter.
Josh
--
Sent via pgsql-sql mailing list (pgsql-sql
Hello, I'm a little new at this so please bear with me.
I am trying to create a function that loads 100M test records into a
database, however I am having a hard time building the function that
does so.
I'm trying to do this in PGAdmin III for Ubuntu. Is there something
that I have wrong
On 05/12/2010 01:32 PM, Josh wrote:
Hello, I'm a little new at this so please bear with me.
I am trying to create a function that loads 100M test records into a
database, however I am having a hard time building the function that
does so.
I'm trying to do this in PGAdmin III for Ubuntu
regexp_matches('foobarbequebaz', $re$(bar)(beque)$re$);
regexp_matches
{bar,beque}
(1 row)
Josh
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
results to a file:
\o myresults.html
Then run a single query:
SELECT col1, col2 FROM foo WHERE bar = '1' ORDER BY baz;
\q
Now you can open your .html file directly into Excel since it's just
a big html table.
Josh
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes
( '{x,y,z}'::TEXT[] );
?column?
--
t
--
--Josh
Josh Berkus
PostgreSQL @ Sun
San Francisco
---(end of broadcast)---
TIP 6: explain analyze is your friend
, not a single array. This means that ANY() doesn't know exactly
what to do with it.
--
--Josh
Josh Berkus
PostgreSQL @ Sun
San Francisco
---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster
I want to limit the number of records returned by an inner join.
Suppose I have a table of Books:
book_id
title
And, a table of authors:
book_id
author_name
Now, suppose I want to get book + author, but I only want one author for
books with multiple authors. Traditionally, I'd do
something like:
for recvar in 'select OLD.'||quote_ident(TG_ARGV[0])...
I THINK you are out of luck here. I hear it's possible to do but in
one of the other PL languages say pl/tcl, though I can't seem to find
an example
Josh
---(end of broadcast
the documentation for
whatever connection library you're interested in using (libpq, JDBC,
npgsql, etc.) to find out what thread-related issues you'll need to
consider using that library.
-Josh
---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster
was doing MySQL and Delphi (again,
it's been years), we didn't use components to talk to the database --
instead, we simply called functions out of libmysql.dll. Were I doing
the same thing with PostgreSQL today, I'd call functions directly from
libpq.dll.
-Josh/eggyknap
---(end
to connect via ODBC. Googling PostgreSQL Delphi
seems to give some useful links.
Delphi should let you use dlls written in other languages (it did when
I used Delphi last, which has been years). So I'd just use libpq.dll.
-Josh
---(end of broadcast
not work/make sense/be possible, etc.
-Josh
---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
AND t.value LIKE 'kro%')
OR (t.field = firsname AND (
t.value LIKE 'jose%' OR t.value LIKE 'andrea%')
)
Not tested. If you're having performance problems is probably less
like that the INTERSECT is the problem with all those LIKE's in
there? Is t.value indexed?
Josh
TABLE1 WHERE (...)
No quoting or server-client-server worries to deal with at all...
Best of luck,
- Josh Williams
---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your
coded either as a list
or that perhaps over-used(?) asterisk. If you really need to pull and use that
from the table definition you'll need two round trips to the server.
Best of luck,
- Josh Williams
---(end of broadcast)---
TIP 6: explain analyze
Kyle,
Nice to hear from you guys again! Action Target was one of the pioneers
of production open source in manufacturing; nice to know that you're
still doing well with it.
--Josh
---(end of broadcast)---
TIP 9: In versions below 8.0
Paul,
Hi is there a way wherein I can interface the pg_dump of PostgreSQL Server
in Visual basic.
I mean for example I want to backup Databases DB1, BD12, DB3 using
pg_dump
You'd have to run them as shell commands in VB. Not sure if VB has a
mechanism for that.
--
Josh Berkus
Aglio
that each row is visited only
once, but it doesn't seem to be possible. Ideas?
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings
-order, which re-orders the *table* so
there's no cascade
3) use the triggers to do the other tree-maintenance stuff, only for their
own rows/children (cascading triggers work *very* well for tree
maintenance).
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
in the PostgreSQL source?
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings
?
Also, if you still have contact, Dave Cramer or Elein should be able to
answer this question ...
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings
Silke,
I have a problem with arrays in Postgres. I want to create a really
large array, lets say 3 billion characters long.
Change your application design.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 2
Mark, Nathan,
I'm moving this over to the PGSQL-SQL list, away from -hackers, as it's no
longer a -hackers type discussion. Hope you don't mind!
On Wed, Sep 07, 2005 at 11:31:16AM -0700, Josh Berkus wrote:
I'm also a little baffled to come up with any real application where
making an id
Joel,
Now I found I had to do something like this just to have a timestamp
(problem is I do not want the format of the time stamp, my clients want to
see the month as a string)
Um, what's wrong with:
to_char(some_timestamp, 'Mon DD HH:MI:SS')
?
--
Josh Berkus
Aglio Database
Tomas,
I've written two on my own (see the functions below),
but maybe there's something faster?
Nope. 'cept I'd combine those two functions into a single function that
returns NULL if the value isn't an integer.
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
are in the /contrib directory where the connectby source is:
/contrib/tablefunc/README.tablefunc
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
reading the 7.1 docs and using 8.0? How about reading the 8.0
docs?
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings
to dumb *g*).
http://techdocs.postgresql.org/guides/SetReturningFunctions
Beware, though, that query plan estimation for SRFs is less accurate than for
regular subqueries, so you could end up with unnecessarily slow query
execution. Test!
--
Josh Berkus
Aglio Database Solutions
San Francisco
your feeback
before writing this procedure?
A proc won't run any faster ... much slower, in fact.Unless you mean that
you want to use it to correct the actual table structure, which is what you
should be doing?
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
not want.
NUMERIC and FLOAT are different data types. Do:
round({value}::NUMERIC, {places})
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings
Sibtay,
As you might have observed here, the actual problem is
how to do assignment to multidimensional array locations using the
subscript operater.
Maybe post your results, too?
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
an explicit transaction wrapping the two inserts.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
that you didn't really name a column time.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
(
field abc_col,
);
I find that DOMAINs give vastly enhanced managability compared to table
constraints.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose
?
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
.
I'm afraid that bibliographic references is a rather esoteric need in the OSS
community.I personally haven't seen such a thing. You may have to create
your own.
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
the trouble of porting an application, you
should port it to something current -- Debian Stable or not. Particularly
since, in a year, you can expect that the PostgreSQL community will probably
stop doing security/stability patches for 7.2.
--
--Josh
Josh Berkus
Aglio Database Solutions
San
on psql (assuming you're using psql; if you're using a GUI tool, that
could be the problem). I've a feeling that your function is erroring out
*before* it gets to the raise.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
from being able to compromise it. It's a security thing.
You could easily write a function in an untrusted language, like PL/PerlU or
PL/PythonU, which would test for file existence and return a true/false
value.
--
Josh Berkus
Aglio Database Solutions
San Francisco
that oracle has stddev_sample and stddev_population.
This is just a wish list.
Were you aware that in PostgreSQL you can write your own aggregates? It's
relatively easy to do.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
::Manip, but use what you like.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings
using it right now, and fixing the
bug is complicated.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
constraints, you have to drop and re-create them under a new
name (do this in a transaction for data safety). However, this requires
knowing what all those constraints do. I'd suggest doing a text pg_dump
file of your schema only (no data) and looking in the constraints section at
the end.
--
Josh
]+)$'
... though that still seems inelegant to me. Is there a regex expert in the
house?
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http
Martin,
I have SQL highlighting, but what I want are colors for the PL/pgSQL
key words. It would make PL programming much easier.
KDE's Kate has PostgreSQL highlighting. Unfortunately, the config is XML so
it's not transferrable to Emacs ...
--
--Josh
Josh Berkus
Aglio Database
.
Well, you'd want to convert the column to a timestamp, and then you could
compute months. Or you could break it in seperate integer year and
month columns and do the same thing.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
prd_data prd2
WHERE prd2.wid = prd1.wid ORDER BY date LIMIT 6) as tot_oil,
(SELECT SUM(hours) FROM prd3
WHERE prd3.wid = prd1.wid ORDER BY date LIMIT 6) as tot_hours
FROM prd_data prd1
ORDER BY wid;
--
Josh Berkus
Aglio Database Solutions
San Francisco
In this last, all dependant objects of, for example, a table (rules, triggers,
indexes, etc. ) would be rolled up into one file. It's this last version
that I personally favor.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
on your
hardware, you could do it procedurally in a programmming language)
3) Then running your aggregate becomes very easy/fast:
SELECT wid, sum(oil) as tot_oil, sum(hours) as tot_hours
FROM prd_data
WHERE months_prod 7
GROUP BY wid
ORDER BY wid;
--
Josh Berkus
Aglio Database Solutions
San
Riccardo,
Looks promising, but still what I need is a proper CVS output, as I
need to review the changes made to the specific database structure.
If it's Perl, I'd be interested in contributing. I've long needed something
like this myself.
--
Josh Berkus
Aglio Database Solutions
San
that has only 6 records per WID.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
.reviewer_id = reviewers.id)
or for a bit faster execution on PG you cann replace that WHERE clause with:
WHERE assign_date IN (SELECT ass2.assign_date FROM assign ass2
WHERE ass2.reviewer_id = reviewers.id ORDER BY ass2.assign_date DESC LIMIT 1)
--
Josh Berkus
Aglio Database Solutions
San
the
original value
Hmmm ... is 15 digits the limit of NUMERIC? It may be.
Is this expected behavior?
Yes.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index
appreciate it if you can do so; it's time we
expanded the number of TSearch languages and efforts like yours are how it
happens.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 2: you can get off all lists at once
Jan,
Because the value in b.y is redundant. b.x-a.x-a.y is exactly the same
value and he even wants to ensure this with the constraint.
And in the absence of that constraint, what ensures that b.y = a.y, exactly?
--
Josh Berkus
Aglio Database Solutions
San Francisco
so
slow that we're going to to the procedural loop. Thanks, all!
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
in standard
SQL to create an FK for it.This is one of the places I point to whenever
we have the SQL is imperfectly relational discussion.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 7: don't forget to increase
I wish this didn't have to be portable
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL
, field_name relates to the same class_name in objects.
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister
. :-(
I'll wait for ASSERTIONS, I think.
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
interested
enough.
However, you have an easy way out:
ALTER TABLE objects ADD CONSTRAINT obj_unq_2 UNIQUE (name, class_name);
This will add the unique constraint that Postgres wants without changing your
data at all.
--
Josh Berkus
Aglio Database Solutions
San Francisco
not allowed to use a custom aggregate or other
PostgreSQL advanced feature)
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister
.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
;
RETURN array_to_string(child_list, '','');
END;' LANGUAGE 'plpgsql';
--
-Josh Berkus
A developer of Very Little Brain
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
Joe,
Are you sure this message isn't coming from some PHP middleware, e.g.
peardb or something. See:
http://us2.php.net/manual/en/function.in-array.php
Hm ... possible. Will check with my PHP guy.
Would explain why I've not been able to track down the error.
--
-Josh Berkus
arrays.
I did try tinkering with some of the functions internals without apparent
effect.
I also checked for in_array and it's not a visible built-in function. Is this
maybe a PostgreSQL bug? Version is 7.4.1
--
-Josh Berkus
A developer of Very Little Brain
Aglio Database Solutions
San
; otherwise you need to do a lot of calculation and querying to figure
out, when Server 11 wants to update Row 283432 of Table status, whether it
can be done locally or needs to be exchanged.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
the modulo is
0 and is less than 70 is a re-occurance.
Overall, though, I've found approach [a] to be easier and more convenient.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ
Kenneth,
but why would anyone want to change the value of an autogenerated serial
row?
But if you're using a real key, it may need to change. The only reason *not*
do do it that way is performance issues with CASCADE.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
issue a WARNING on any time you create a
table in PG without a key.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
be incorrect and surrogate keys make it easier to make design
changes in production.
Once again, though, this is an *implementation* issue and not a *logic* issue,
as I asserted ...
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
in the state yet where we want it but we are
getting there - or so I think.
When I have time, sure! But, this afternoon I am off to OSCON so I won't
have a chance for 2 weeks at least. Drop me a personal e-mail in August so I
don't forget.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
. Otherwise, you have more than database
problems. And it prevents you from having to rely on a flaky long text key.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ
ases" I've encountered which contained tables with a surrogate key, and
NO REAL KEY of any kind. This makes data normalization impossible, and
cleanup of the database becomes a labor-intensive process requiring
hand-examination of each row.
--
-Josh Berkus
Agli
the speed of CASCADE operations whenever a
type_name changes. If these changes occur extremely infrequently, then you
can ignore this as well.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 7: don't forget
Sad,
First of all, please excuse me if I've misunderstood you below because of
translation issues. You'll find I'm rather strident, but it's because the
reasons you're presenting, or seem to be, are excuses for bad database design
I hear every day on the job, and end up having
Sad,
can anyone comment the announcement of 7.5
about nested transactions ?
doesn't the nesting hurt the matter of transaction ?
7.5 hasn't been announced. It's not even in beta.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
=0.00..606.60 rows=14544 width=33)
Filter: (route = '62.1.1.0/24'::cidr)
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
=14544 width=33)
Filter: (route = '62.1.1.0/24'::cidr)
Oh, and also a SELECT VERSION(); would be nice.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
that the = query is returning 60% of your table,
which makes indexes useless.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs
every other programming language in
existance ...
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
Hannes,
does anyone know how it is posible to set a composite type as the data
type of a column when creating a new table?
This is not yet supported. Hopefully it will be supported in the upcoming
version 7.5.
--
Josh Berkus
Aglio Database Solutions
San Francisco
is that the cursor isn't returning what you think it is, and is looping
several times ... thus attempting to insert the same value several times.
Good luck!
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 1: subscribe
? Or is there maybe an even better
way to structure my data?
Thanks for any contribution!
Roelant.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
)
VARCHAR
CHAR
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 8: explain analyze is your friend
? Normalized designs are
almost always easier to deal with from a perspective of long-term
maintainence.
The arrays, as far as I can tell, gain you nothing in ethier performance or
convenience.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast
for this...
Please re-post this with your table design in the body of your e-mail, and NO
doc attachment.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send
statement.
Sort of. See the Docs on Runtime Configuration on the GUC variable
Datestyle.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http
were getting SQL on this project. Now the big vendors -- mostly IBM and
Oracle since Informix and Sybase are dying -- run everything and adapt the
standard to what features their products already have.
So, yes, SQL92 needed development and expansion. But we didn't need SQL99.
--
Josh Berkus
.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 8: explain analyze is your friend
James,
Would recursive queries be the trick to doing things like unwinding a
linked-list to either the head or tail, with:
Yes. Also check out contrib/ltree and contrib/tablefunc in your handy-dandy
PostgreSQL source code.
--
Josh Berkus
Aglio Database Solutions
San Francisco
the individual columns, or
2) Use PL/tcl, PL/Pyton, or C where you can select columnns by ordinal
position or other dynamic factor.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 3: if posting/reading through
that paragraph makes me
think that the type is somehow supposed to contain metadata or summary data
for the table itself.
--
Josh Berkus
Aglio Database Solutions
San Francisco
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send
1 - 100 of 710 matches
Mail list logo