Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Tom Lane
, and it does that by converting the record value to text ... which produces the parenthesized data format specified at http://www.postgresql.org/docs/8.0/static/rowtypes.html#AEN5604 regards, tom lane ---(end of broadcast)---

Re: [SQL] why vacuum

2005-10-26 Thread Tom Lane
"Bath, David" <[EMAIL PROTECTED]> writes: > ... Note that Sybase/MS-SQL's > check constraint model asserts the constraint BEFORE the trigger, which > discourages you from attempting to check and handle meaning of data! Er, doesn't PG do it that way too?

Re: [SQL] why vacuum

2005-10-25 Thread Tom Lane
some idea about doing more work during low-load periods. Unless MySQL invents some concept equivalent to VACUUM, they won't have any prayer at all of being able to shift maintenance overhead to low-load times. regards, tom lane ---(end of broadcast

Re: [SQL] broken join optimization? (8.0)

2005-10-25 Thread Tom Lane
e for such a case, the way it does for constant-false top level WHERE clauses, but I really doubt it's worth any extra cycles at all to make this happen. The proposed example is quite unconvincing ... why would anyone want to depend on the existence of a "dual" table rather tha

Re: [SQL] Delete rule chain stops unexpectedly

2005-10-25 Thread Tom Lane
Wiebe Cazemier <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Because the rule converts those inserts into, effectively, >> >> INSERT INTO debuglog SELECT ... WHERE EXISTS(some matching OLD row); >> >> and there are no longer any matching OLD rows in the

Re: [SQL] convert timezone to string ...

2005-10-25 Thread Tom Lane
"Marc G. Fournier" <[EMAIL PROTECTED]> writes: > I know that the server knows that ADT == -0400, and AST == -0300 ... Other way around isn't it? Unless Canada observes a pretty strange variety of daylight saving time ;-) regards, tom lane ---

Re: [SQL] Blank-padding

2005-10-24 Thread Tom Lane
"Shaun Watts" <[EMAIL PROTECTED]> writes: > Is there any way to eliminate the blank padding at the end of character > fields in a table. Use varchar, or text. regards, tom lane ---(end of broadcast)-

Re: [SQL] Blank-padding (was: Oracle buys Innobase)

2005-10-21 Thread Tom Lane
;t significant. This gripe seems to me exactly comparable to complaining if a numeric datatype doesn't remember how many trailing zeroes you typed after the decimal point. Those zeroes aren't semantically significant, so you have no case. regards, tom lane ---

Re: [SQL] Delete rule chain stops unexpectedly

2005-10-21 Thread Tom Lane
Wiebe Cazemier <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Hmm ... this appears to be a bug in EXPLAIN ANALYZE: it really should >> bump the CommandCounter between plan trees, but fails to ... > Is this something I have to report? Nah, I fixed it already

Re: [SQL] Delete rule chain stops unexpectedly

2005-10-21 Thread Tom Lane
Wiebe Cazemier <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >>> The rule that actually deletes the rows from the underlying has to fire >>> last, since the rows are gone from the view (and hence from OLD) the >>> moment you delete them. > A quote from the p

Re: [SQL] Delete rule chain stops unexpectedly

2005-10-21 Thread Tom Lane
(and hence from OLD) the moment you delete them. In practice, you'd be way better off using an ON DELETE trigger for these tasks. regards, tom lane ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Postgres 7.4.9 slow!

2005-10-21 Thread Tom Lane
that these might be two different machines; certainly two very different compilers were used. One thing I'd wonder about is whether both databases were initialized in the same locale. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] casting character varying to integer - order by numeric sort

2005-10-19 Thread Tom Lane
han that about which version you are working with ;-) You may find that username::text::integer will work, depending on which 7.x this actually is. regards, tom lane ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] NULL in IN clause

2005-10-19 Thread Tom Lane
s per spec. The computation is effectively NOT (0 = NULL OR 0 = 1) NOT (NULL OR FALSE) NOT NULL NULL ie, the result is UNKNOWN, which WHERE treats the same as FALSE. regards, tom lane ---(end of broadcast)

Re: [SQL] FULL OUTER JOIN Question

2005-10-14 Thread Tom Lane
ere's the rows with trans_item.parent=20116?) regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] owner of data type "areas" appears to be invalid ?

2005-10-14 Thread Tom Lane
has ... regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] pg, mysql comparison with "group by" clause

2005-10-13 Thread Tom Lane
into the spec that neither Oracle nor IBM intended to implement. Those two pretty much control the committee after all ... regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] pg, mysql comparison with "group by" clause

2005-10-13 Thread Tom Lane
*was* true, in SQL92, but SQL99 lets you omit unnecessary GROUP BY columns. The gripe against mysql, I think, is that they don't enforce the conditions that guarantee the query will give a unique result. The gripe against postgres is that we haven't implemented the SQL99 semant

Re: [SQL] UPDATE Trigger on multiple tables

2005-10-12 Thread Tom Lane
No. You can use the same function for multiple triggers, but you have to CREATE TRIGGER for each table separately. regards, tom lane ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://

Re: [SQL] Update timestamp on update

2005-10-12 Thread Tom Lane
languages first, but obviously it's not getting the job done. Anybody have a better idea? regards, tom lane ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] pg, mysql comparison with "group by" clause

2005-10-12 Thread Tom Lane
d I don't think we want to tackle all of it any time soon, but the primary-key case probably wouldn't be very hard to implement. We really ought to have this in TODO ... I'm sure it's been discussed before. regards, tom lane ---(e

Re: [SQL] Update timestamp on update

2005-10-12 Thread Tom Lane
way to solve it. See the documentation about triggers. The first example on this page does it along with a few other things: http://developer.postgresql.org/docs/postgres/plpgsql-trigger.html regards, tom lane ---(end of broadcast)--

Re: [SQL] Text->Date conversion in a WHERE clause

2005-10-12 Thread Tom Lane
queries involving views (since a view is nothing but a macro for a sub-select). regards, tom lane ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] Text->Date conversion in a WHERE clause

2005-10-12 Thread Tom Lane
pposing that WHERE clauses are guaranteed to be evaluated in a particular order. Such guarantees are made only for a very few specific constructs such as CASE. See http://www.postgresql.org/docs/8.0/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL regards, tom lane -

Re: [SQL] ichar

2005-10-11 Thread Tom Lane
Judith Altamirano Figueroa <[EMAIL PROTECTED]> writes: > ERROR: not exist the function ichar(integer) [ digs in archives... ] Looks like we renamed ichar() to chr() quite some time ago. regards, tom lane ---(end of

Re: [SQL] question re. count, group by, and having

2005-10-11 Thread Tom Lane
gregates. This isn't necessarily true for other forms of common subexpressions, but it works for aggregate functions. regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] How to delete Large Object from Database?

2005-10-10 Thread Tom Lane
ata_pic lo, > CONSTRAINT t_data_pic_pkey PRIMARY KEY ("sysid") > ) > WITH OIDS; > ALTER TABLE t_data_pic OWNER TO admin; Why am I not seeing any trigger attached to this table? That lo_manage trigger is the useful part of contrib/lo --- the separate data

Re: [SQL] UNION index use help

2005-10-06 Thread Tom Lane
ou're getting burnt because you're unioning a text with a varchar. Make the column types the same and it'll work better. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Scripting GRANT on functions

2005-10-06 Thread Tom Lane
rocedure from pg_proc limit 5; oid -- boolin(cstring) boolout(boolean) byteain(cstring) byteaout(bytea) charin(cstring) (5 rows) regression=# regards, tom lane ---(end of broadcast)--- T

Re: [SQL] Use of partial index

2005-10-05 Thread Tom Lane
ON events (event_id) WHERE tag_type_fk = 2; then it would be competitive for this query, since the index could effectively handle both constraints not just one. (THe way you did define it, the actual content of the index keys is just dead weight, since they obviously must all be "2".

Re: [SQL] MOVE in SQL vs PLPGSQL

2005-10-05 Thread Tom Lane
at sounds fiddly. > I must admit, on the odd occasion I want to skip a row, I just FETCH it > and move on. Anyone else? There is something on the TODO list about improving plpgsql's cursor functionality --- there's no reason it shouldn't have MOVE, except that no one got ar

Re: [SQL] using pg_tables and tablename in queries

2005-10-04 Thread Tom Lane
on in which you should rethink your data design. Those tables should all get merged into one big table, adding one extra column that reflects what you had been using to segregate the data into different tables. regards, tom lane ---(end of broadcast)---

Re: [SQL] combination of function to simple query makes query slow

2005-10-04 Thread Tom Lane
expressing the query without that. My guess is that trying to use a function for this is counterproductive in itself; the table access that's going on inside the function needs to be exposed for optimization in order to get reasonable overall performance.

Re: [SQL] Problem with function and trigger...

2005-09-28 Thread Tom Lane
_sync" line 2 at if > What am I failing to understand with this? We don't guarantee short-circuit evaluation of boolean expressions. You'll have to break that into two IFs, ie, IF TG_OP = 'DELETE' THEN IF ... test on OLD.something ...

Re: [SQL] Why doesn't the SERIAL data type automatically have a UNIQUE CONSTRAINT

2005-09-26 Thread Tom Lane
ent that no one has a use for it ... regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] redundancy in CHECK CONSTRAINTs

2005-09-24 Thread Tom Lane
;s still true in the latest spec. Postgres treats column constraints and table constraints alike, but other SQL databases are likely to be pickier. BTW, is there any actual need for the "id" column here, seeing that you have a natural primary key?

Re: [SQL] Where are user defined functions stored?

2005-09-23 Thread Tom Lane
might want to exclude stuff in information_schema as well. regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Where are user defined functions stored?

2005-09-23 Thread Tom Lane
Hilary Forbes <[EMAIL PROTECTED]> writes: > How can I easily get to see the definition of a user defined function > please? Look in pg_proc. regards, tom lane ---(end of broadcast)--- TIP 3: Have you checked o

Re: [SQL] Issue with UPDATE statement on v8

2005-09-22 Thread Tom Lane
issue? We'd certainly have heard about it if so. But you haven't provided enough info to let anyone reproduce the problem for investigation. regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] delete item[5] from varchar[] array???

2005-09-21 Thread Tom Lane
Matthew Peter <[EMAIL PROTECTED]> writes: > How is it possible to delete an item from a single > dimension varchar[] array? AFAIR there is no built-in function for this, but it seems like you could write a generic polymorphic function for it easily enough.

Re: [SQL] R-tree and start/end queries

2005-09-21 Thread Tom Lane
is still a possible problem. regards, tom lane ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] Triggers & Conditional Assignment

2005-09-15 Thread Tom Lane
onal assignment doesn't seem to be catered for. The equivalent construct in SQL is CASE. regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] CREATE TEMPORARY TABLE ON COMMIT DROP

2005-09-14 Thread Tom Lane
Luis Sousa <[EMAIL PROTECTED]> writes: > But how can I create a table using a query and putting ON COMMIT DROP. You can't. Use INSERT ... SELECT to fill the table, instead. regards, tom lane ---(end of broadcast)---

Re: [SQL] user defined type, plpgsql function and NULL

2005-09-12 Thread Tom Lane
uot;fbt IS NULL" should yield true in your example, but I think there are/were some implementation reasons why it doesn't. regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignor

Re: [SQL] Please help, can't figure out what's wrong with this function...

2005-09-12 Thread Tom Lane
der server. Try 7.4 or later --- plpgsql was pretty weak on handling rowtype variables that far back. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Panic: Page Add Item: Corrupted page pointers

2005-09-11 Thread Tom Lane
will hose the DB completely, so don't do it till you've exhausted the possibilities for pg_dump without it. Consider updating to a more recent PG release while you are recovering... regards, tom lane ---(end of broadcast)---

Re: [SQL] SELECT: retrieve only 2 rows next to known row

2005-09-09 Thread Tom Lane
required ordering or the nature of the condition that defines "this row" to really say much about the best solution. regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Numeric Columns

2005-09-08 Thread Tom Lane
than 10.0 the > column should return the relevant values. However, the column needs to be > able > to hold values like "<0.05". contrib/seg might do more or less what you're looking for, but none of the standard datatypes will.

Re: [SQL] queries problems

2005-09-08 Thread Tom Lane
n int2vector *is* an int2 array, so = ANY just works. regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] Indexing an array?

2005-09-08 Thread Tom Lane
Don't try to use arrays to replace tables. regards, tom lane ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] AGE function

2005-09-07 Thread Tom Lane
ix timestamptz_age() to do calculation in local timezone not GMT, per bug 1332. and here is a link to the discussion that prompted the change: http://archives.postgresql.org/pgsql-bugs/2004-12/msg00013.php regards, tom lane ---(end of br

Re: [SQL] Equivalent of Oracle SQL%NOTFOUND in plpgsql

2005-09-05 Thread Tom Lane
QL-STATEMENTS-DIAGNOSTICS regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] POSIX Regular Expression question

2005-09-05 Thread Tom Lane
ependent --- or at least should be. The locale support in our regexp code is definitely pretty weak at the moment. regards, tom lane ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] Recommendation on bytea or blob for binary data like images

2005-09-02 Thread Tom Lane
ly no API to read and write bytea values in a streaming fashion. If your objects are small enough that you can load and store them as units, bytea is fine. BLOBs, on the other hand, have a number of drawbacks --- hard to dump, impossible to secure, etc.

Re: [SQL] [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-09-01 Thread Tom Lane
, you might have to make the cast IMPLICIT rather than ASSIGNMENT. I'd try ASSIGNMENT first, though, since it's less likely to bite you when you weren't expecting it. regards, tom lane ---(end of broadcast)---

Re: [SQL] insert only if conditions are met?

2005-08-31 Thread Tom Lane
(ofsomething)>0 = > ) > Is this possible at all with just plain SQL? Instead of INSERT ... VALUES, use INSERT ... SELECT. regards, tom lane ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] [GENERAL] How do I copy part of table from db1 to db2 (and

2005-08-31 Thread Tom Lane
different encodings then you are in for some pain. At the minimum you'll have to separate out the rows that are in each encoding so you can pass them through different conversion processes. regards, tom lane ---(end of broadcast)---

Re: [SQL] Unwanted nested dollar-quoted constants

2005-08-27 Thread Tom Lane
data. It's possible to develop appropriate code for dollar-quoting random text, but it's a lot harder than it is to escape the data in the old style. regards, tom lane ---(end of broadcast)--- TIP 3: Have you che

Re: [SQL] Can EXCEPT Be Used for To Solve This Problem?

2005-08-24 Thread Tom Lane
"Lane Van Ingen" <[EMAIL PROTECTED]> writes: > I want to select 2nd oldest transaction from foo (transaction 3). Can't you just do select * from foo order by update_time desc offset 1 limit 1 regards, tom lane

Re: [SQL] Problem calling stored procedure

2005-08-23 Thread Tom Lane
ate, end_date) OVERLAP (new_start_date, new_end_date) AND property_id = X; As far as the reason for the difference between function execution and manual execution: check for unintended variable substitutions. Which words in the query match variable names in the plpgsql function? Are those only th

Re: [SQL] Problem with self-made plpgsql-function / casting

2005-08-20 Thread Tom Lane
select fc_editlanguage(42, 'foo', 'bar', 1::smallint); This is enough of a notational pain in the neck that it's easier just to declare the argument as integer. regards, tom lane ---(end of broadcast)

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Tom Lane
vector in pre-8.1 releases, so I think you're kinda stuck with the above for now. regards, tom lane ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] Is it This Join Condition Do-Able?

2005-08-17 Thread Tom Lane
Mischa Sandberg <[EMAIL PROTECTED]> writes: > Anyone care to comment on the third row of output? I think you mistyped the last INSERT: > insert into c values(2, 'C2'); > insert into b values(3, 'C3'); I suppose you meant insert into c ...

Re: [SQL] Parentheses in FROM clause and evaluation order.

2005-08-15 Thread Tom Lane
the same effect on SQL-data and schemas as that sequence. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Tom Lane
Michael Fuhr <[EMAIL PROTECTED]> writes: > On Mon, Aug 15, 2005 at 08:21:23PM -0400, Tom Lane wrote: >> Given that we consider trailing spaces in char(n) to be semantically >> insignificant, would it make sense to strip them before doing the >> regex pattern match? >

Re: [SQL] Problem with a Pettern Matching Check

2005-08-15 Thread Tom Lane
tra ~ operator definition that specifically prevents that (bpcharregexeq). I have a feeling that we added that operator definition at some point for backwards compatibility, but it seems a bit odd now. regards, tom lane ---(end of broadcast)--

Re: [SQL] insert into / select from / serial problem

2005-08-14 Thread Tom Lane
ust let it default, which you'd do with, say, INSERT INTO newtable (fielda, fieldb) SELECT field1, field2 FROM anothertable regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore y

Re: [SQL] about subselect

2005-08-11 Thread Tom Lane
and B01.tglavd <= A38.tglavd) > )A > Where Temp_hasil2.NIK = A.NIK; regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: **SPAM** [SQL] Faster count(*)?

2005-08-09 Thread Tom Lane
ded to supply a simpler API if there's enough demand for it. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Calling SQL functions that return sets

2005-08-01 Thread Tom Lane
Chris Mungall <[EMAIL PROTECTED]> writes: > On Mon, 1 Aug 2005, Tom Lane wrote: >> Chris Mungall <[EMAIL PROTECTED]> writes: >>> What are the reasons for deprecating the use of the function in the >>> SELECT clause? >> >> The semantics of

Re: [SQL] Calling SQL functions that return sets

2005-08-01 Thread Tom Lane
e because (as you note) there are things you can't do any other way. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] bug in information_schema?

2005-07-30 Thread Tom Lane
might be, if there can be multiple pg_depend entries linking the same entities. Peter, any thoughts? regards, tom lane ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate

Re: [SQL] REINDEX DATABASE

2005-07-27 Thread Tom Lane
which might not be infinite bloat but it's surely not too efficient. regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Different encodings in different DBs in same cluster

2005-07-24 Thread Tom Lane
ow anything about case-folding for non-ASCII characters. But it will at least give consistent results. When you use a non-C locale, it's best to stick to the encoding that the locale expects. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Error when using array variable

2005-07-22 Thread Tom Lane
ecause > of the dollar quotes. However, plpgsql wasn't fixed to follow that behavior till 8.0.2 or so. regards, tom lane ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Can SELECT statements throw an error

2005-07-21 Thread Tom Lane
nk that most errors in the "data exception", "cardinality violation", "insufficient resources", and "operator intervention" categories are possible. See the error codes appendix for some ideas. And of course, if the SELECT invokes a user-defined function,

Re: [SQL] Dumping table definitions

2005-07-18 Thread Tom Lane
definitions. I can do > awk and sed commands to do this if I need to, but first wanted to check > if Pg already had tools to export the table structure (without the > data). Does it? pg_dump with the -s switch is a much better way ... regards, tom lan

Re: [SQL] problem (bug?) with "in (subquery)"

2005-07-15 Thread Tom Lane
Luca Pireddu <[EMAIL PROTECTED]> writes: > On July 15, 2005 08:58, Tom Lane wrote: >> Ah-hah: this one is the fault of create_unique_path, which quoth > In any case, it looks like Tom has already found the problem :-) Thanks guys! On closer analysis, the test in create_unique_

Re: [SQL] problem (bug?) with "in (subquery)"

2005-07-15 Thread Tom Lane
ath, which quoth /* * If the input is a subquery whose output must be unique already, we * don't need to do anything. */ Of course, that needs to read "... unique already, *and we are using all of its output columns in our DISTINCT list*,

Re: [SQL] problem (bug?) with "in (subquery)"

2005-07-15 Thread Tom Lane
ally have time to reverse-engineer a test case from your description ... regards, tom lane ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Copy user privileges

2005-07-12 Thread Tom Lane
on pg_shadow would get the job done just as well. regards, tom lane ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that

Re: [SQL] Make COUNT(*) Faster?

2005-07-10 Thread Tom Lane
Harald Fuchs <[EMAIL PROTECTED]> writes: > FOR row IN EXECUTE 'EXPLAIN SELECT * FROM ' || tbl LOOP > fails with the following message: > ERROR: cannot open non-SELECT query as cursor [ checks CVS history... ] Use 8.0.2 or later.

Re: [SQL] Make COUNT(*) Faster?

2005-07-08 Thread Tom Lane
Steve Wampler <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> If you want something cheap, you could use the same technique the >> planner uses nowadays: take RelationGetNumberOfBlocks() (which is >> guaranteed accurate) and multiply by reltuples/relpages. > Ye

Re: [SQL] Index creation question for expression (col1 || '-' || col2)

2005-07-08 Thread Tom Lane
Ying Lu <[EMAIL PROTECTED]> writes: > A question about creating index for the following expression. > CREATE INDEX idx_t1 ON test (col1 || '-' || col2); You need more parentheses: CREATE INDEX idx_t1 ON test ((col1 || '-' || col2));

Re: [SQL] Make COUNT(*) Faster?

2005-07-08 Thread Tom Lane
functions to provide this functionality. regards, tom lane ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Make COUNT(*) Faster?

2005-07-07 Thread Tom Lane
via triggers for specific tables that you think it's worth doing for. Also, if an approximate answer is good enough, there are a whole other set of possible solutions. regards, tom lane ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Prepare plan in plpgsql

2005-07-06 Thread Tom Lane
Jocelyn Turcotte <[EMAIL PROTECTED]> writes: > i'm wondering if there is a way to prepare and execute a plan in a > plpgsql function. You do not need that because plpgsql automatically caches plans for SQL statements appearing in a plpgsql function.

Re: [SQL] left joins

2005-07-06 Thread Tom Lane
s of PG actively recognize this case and reduce the LEFT JOIN to plain JOIN, but even if we did not do that you'd get the same result. I've heard it claimed that Oracle produces different results; if true, it must have something to do with their rather standards-challenged interpre

Re: [SQL] 'show full processlist' in postgres?

2005-07-01 Thread Tom Lane
Erik Wasser <[EMAIL PROTECTED]> writes: > But 'current_query' is still always empty... B-( The pg_stats views lag reality by a certain amount, so checking for your own query is generally not gonna work. Try starting a long-running query in another session.

Re: [SQL] Foreign key pg_dump issue and serial column type

2005-06-29 Thread Tom Lane
t fails: > ERROR: type "serial" does not exist Serial isn't quite a true type, and so it doesn't work in every context that you might think. It'd probably make sense for "alter column type" to accept it, but for now what you gotta do is create a sequence

Re: [SQL] ENUM like data type

2005-06-29 Thread Tom Lane
tgreSQL hasn't > implemented it. It's not that hard to make your own type using the builtin textin and textout functions, and then add just the functions you wish to provide. regards, tom lane ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] empty view, replace view, column type change?

2005-06-24 Thread Tom Lane
Bruce Momjian writes: > Tom Lane wrote: >> but it doesn't seem to me to follow from what the spec says that we need >> to explicitly cast the result of now() to six places. As long as it's >> coming from gettimeofday it can't have more than 6 places anyway,

Re: [SQL] empty view, replace view, column type change?

2005-06-23 Thread Tom Lane
l when presented with this parse tree.) In short, I'm inclined to remove the above-quoted lines, and similarly for CURRENT_TIME, CURRENT_TIMESTAMP, and LOCALTIME. Thoughts? regards, tom lane ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] optimizer, view, union

2005-06-23 Thread Tom Lane
some type-conversion issues. (You don't really want them in the output of a view anyway; "unknown" type columns are bad news.) regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Tom Lane
r was O(N^2) in the number of rows affected, and would surely be intolerably slow for multiple deletes in a reasonably sized table. Given an index on the grouping columns plus sort_order, it could even be reasonably fast (don't forget to make the ORDER BY match the index).

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Tom Lane
leted in decreasing order of c, and there's no very easy way to guarantee that. regards, tom lane ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Putting an INDEX on a boolean field?

2005-06-19 Thread Tom Lane
hing convert_IN_to_join() to attach the IN subselect further down in the join tree, using logic similar to what we use to decide where ordinary WHERE quals can bubble down to. regards, tom lane ---(end of broadcast)--- TIP 9: th

Re: [SQL] WHY transaction waits for another transaction?

2005-06-19 Thread Tom Lane
workaround I know of is to make the foreign key checks all deferred, so that they're not checked until the transaction is about to commit. This is not bulletproof, but because it considerably reduces the time window for a conflict, it may do as a workaround until 8.1 is ready.

Re: [SQL] partial index on non default tablespace syntax

2005-06-18 Thread Tom Lane
REATE INDEX (I hadn't bothered to make a tablespace to test with, but the point is the syntax is fine.) regards, tom lane ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Putting an INDEX on a boolean field?

2005-06-16 Thread Tom Lane
"Marc G. Fournier" <[EMAIL PROTECTED]> writes: > Does that make sense? Would it ever get used? It could get used if one of the two values is far less frequent than the other. Personally I'd think about a partial index instead ...

<    5   6   7   8   9   10   11   12   13   14   >