[SQL] trigger viewing

2002-08-29 Thread Kemin Zhou

Dear Friends,
Some times when we create foreign keys we
find these type of things
after \d table
Triggers: RI_ConstraintTrigger_39656710,
  RI_ConstraintTrigger_39656716

These trigger could be this table using foreigin keys from
other table or vis versa.

I don't know how to figure out what are defined in
the triggers.  

Is there any things like \d trigger ?

Kemin



---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



[SQL] bytea ,etc.

2002-08-29 Thread Klimov Andrew



Hi , All!
 
Could someone clarify me  :
 
When I want to store BLOB's internally in database 
(for example jpeg )
should I use bytea or OID? Is OID something like 
BFILE in Oracle 8i?
If both are appropriate why I can't 
use
update image set picture=lo_import('Myfile') where 
image_code='blablabla' 
with bytea column type but only with OID column 
type?
 
And one more thing:
Where is function byteain documented?
 
TIA,
Andrew.


[SQL] sql statement to give functionality of \d tablename?

2002-08-29 Thread Philip Rudling

Is the an SQL statement that can be used from within a program that will
give the output of \d command?  Like the describe command in MySQL's version
of SQL?

SR



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [SQL] sql statement to give functionality of \d tablename?

2002-08-29 Thread Lee Harr

In article <[EMAIL PROTECTED]>, Philip Rudling wrote:
> Is the an SQL statement that can be used from within a program that will
> give the output of \d command?  Like the describe command in MySQL's version
> of SQL?
> 


There is a flag to psql which will show you the sql from the
backslash commands. I believe it is -E, but check the manpage.


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[SQL] signed/unsigned integers

2002-08-29 Thread Roger Mathis

Hi

Is it true, that I can't define unsigned integers in a table definition?

CU Roger




---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [SQL] signed/unsigned integers

2002-08-29 Thread Bruno Wolff III

On Fri, Aug 23, 2002 at 11:11:51 +0200,
  Roger Mathis <[EMAIL PROTECTED]> wrote:
> Hi
> 
> Is it true, that I can't define unsigned integers in a table definition?

If the main issue is that there not be negative numbers, you can use a
constraint to enforce this. In 7.3 you can define a domain with the
constraint and use it similar to a type.

If you need 32-63 bits worth of information, then you can use bigint with
some performance penalty. If you need 64 bits or more of information,
then you might be able to use numeric with an even larger performance hit.

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: [SQL] union optimization in views

2002-08-29 Thread Josh Berkus

Joe,

> We are attempting to move a couple of systems from Oracle to Postgres but 
can not do so without application rewrites due to the current use of views 
with UNIONs and the criticality of the performances of these views.
> 
> I was wondering if a decision has been made on the optimization with the 
UNION clause in views.  There are many documents in the SQL archive showing 
that the "push down" is not occuring and thus the use of UNION's in views is 
limited to case where the data set is small or performance is not a 
consideration.  I also looked through the TODO list and didn't see anything 
(of course I could have missed references).  

I'd take this up on PGSQL-HACKERS.   The UNION VIEW optimization, last I 
checked, was stalled mainly because nobody wanted to work on it.  Maybe you 
can?

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[SQL] record count

2002-08-29 Thread Marie G. Tuite


Hello list,

Is there a system attribute or table or ? providing record count by table? 

Thanks. 


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: [SQL] record count

2002-08-29 Thread Bruno Wolff III

On Thu, Aug 29, 2002 at 13:37:40 -0500,
  "Marie G. Tuite" <[EMAIL PROTECTED]> wrote:
> 
> Is there a system attribute or table or ? providing record count by table? 

No. Normally you use the count aggregate to obtain that information.
However if you do few updates and need this information fairly often,
then you may want to keep the data in your own table using triggers.

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



[SQL] the optimizer and exists

2002-08-29 Thread Thomas F. O'Connell

i think i might've stumbled across a tiny defect in the optimizer. 
unfortunately, i haven't the knowledge of the code to know where to 
begin looking at how to address this problem.

anyway, consider the following:

create table foo(
id int2
);

create table bar(
id int2
foo_id int2 references foo( id )
);

imagine that the tables are populated.

now, consider the query

select b.foo_id
from bar b
where b.id = 
and
exists(
select *
from foo f
where b.foo_id = f.id
and b.id = 
);

now consider the same query with "select " in place of "select 
*" in the EXISTS subquery.

explain analyze indicates that the constant version always runs a little 
bit faster. shouldn't the optimizer be able to determine that it isn't 
necessary actually to read a row in the case of EXISTS? i'm assuming 
that's where the overhead is coming into play.

i realize this is minutiae in comparison to other aspects of 
development, but it is another small performance boost that could be 
added since i imagine many people, myself included, find it more natural 
to throw in "select *" rather than "select ".

i didn't see this on the current lists or TODO, but if it's a dupe, i 
apologize for the noise. i also apologize for not being able to patch 
it, myself!

-tfo


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: [SQL] record count

2002-08-29 Thread Bhuvan A

> 
> Hello list,
> 
> Is there a system attribute or table or ? providing record count by table? 
> 
> Thanks. 
> 

pg_class.reltuples has the record count.

regards,
bhuvaneswaran



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html