Re: [SQL] Multicolum index and primary key

2003-11-18 Thread Michele Bendazzoli
On Mon, 2003-11-17 at 18:13, Tomasz Myrta wrote: > Dnia 2003-11-17 19:00, Użytkownik Michele Bendazzoli napisał: > > a is always present in the queries ... and other that (a, ab, abc) i > > have only to query (ac): so I think I have to index separately only > > (ac). > > For such cases consider ch

Re: [SQL] Quota query with decent performance?

2003-11-18 Thread Bruno Wolff III
On Mon, Nov 17, 2003 at 23:55:53 +0100, Troels Arvin <[EMAIL PROTECTED]> wrote: > On Tue, 11 Nov 2003 18:49:31 -0500, Chester Kustarz wrote: > > [... discussion of top-n query (where n=3) ...] > > > select * > > from person > > where age <= > > (select age from person order by age limit 1 offse

Re: [SQL] Quota query with decent performance?

2003-11-18 Thread Troels Arvin
On Tue, 18 Nov 2003 06:56:42 -0600, Bruno Wolff III wrote: > select * > from person > where not isfalse (age <= > (select age from person order by age limit 1 offset 2)); Thanks; much nicer than my COALESCE-variant. http://troels.arvin.dk/db/rdbms/#select-top-n-postgresql updated. -- Greetings

Re: [SQL] Quota query with decent performance?

2003-11-18 Thread Troels Arvin
On Tue, 18 Nov 2003 06:56:42 -0600, Bruno Wolff III wrote: [...] > where not isfalse (age <= [...] Strange. I can't find the ISFALSE in neither PostgreSQL or standard SQL documentation. How can that be? -- Greetings from Troels Arvin, Copenhagen, Denmark ---(end of br

Re: [SQL] Quota query with decent performance?

2003-11-18 Thread Bruno Wolff III
On Tue, Nov 18, 2003 at 15:21:43 +0100, Troels Arvin <[EMAIL PROTECTED]> wrote: > On Tue, 18 Nov 2003 06:56:42 -0600, Bruno Wolff III wrote: > > [...] > > where not isfalse (age <= > [...] > > Strange. I can't find the ISFALSE in neither PostgreSQL or standard SQL > documentation. How can that

Re: [SQL] Quota query with decent performance?

2003-11-18 Thread Bruno Wolff III
On Tue, Nov 18, 2003 at 15:21:43 +0100, Troels Arvin <[EMAIL PROTECTED]> wrote: > On Tue, 18 Nov 2003 06:56:42 -0600, Bruno Wolff III wrote: > > [...] > > where not isfalse (age <= > [...] > > Strange. I can't find the ISFALSE in neither PostgreSQL or standard SQL > documentation. How can that

Re: [SQL] Quota query with decent performance?

2003-11-18 Thread Troels Arvin
On Tue, 18 Nov 2003 08:36:27 -0600, Bruno Wolff III wrote: > The standard syntax is expression is false instead of > isfalse(expression) OK, so I guess that a 'better' (closer to standard) version of your query would be: SELECT * FROM pview WHERE ( age <= ( SELECT age FROM pview ORDER

[SQL] Need query to separate rows by one field's value

2003-11-18 Thread Jeff Boes
Here's a query challenge for you. Given: table foo ( a integer primary key, b integer check (b > 0)) with a limited number of rows (say, <= 10). Values in column "a" are unique (obviously). Values in column "b" are not. I want to find a set of values for "a" such that the sum of "b" values

Re: [SQL] Addition and subtraction on BIT type

2003-11-18 Thread Yasir Malik
Thank you for your reply. select int4(b'1001')::bit(32); gives the same result as what you gave. select int4(b'1001')::bit(4); gives the upper four bits, which are all zeroes. How would I get the lower four bits? I building bitmaps using plpgsql, and therefore, I will be doing a lot bit manipulat

[SQL] Function ROWTYPE Parameter with NEW/OLD

2003-11-18 Thread Andrew Milne
Postgres 7.2.1 I'm trying to create a function that takes a ROWTYPE parameter that I can then call from a rule by passing NEW/OLD, but am having problems. CREATE OR REPLACE FUNCTION "some_boolean_function" (mytablename) RETURNS boolean AS ' DECLARE mytable ALIAS FOR $1;

Re: [SQL] Array fields in Postgresql...

2003-11-18 Thread Randolf Richardson, DevNet SysOp 29
> Can any one give me a link/tutorial for using arrays in databases..I > need Queries to access the arrays as well... A quick search in Google.Com yielded a number of results which included the following: PostgreSQL Tutorial http://www.eskimo.com/support/P

[SQL] type conversion needed

2003-11-18 Thread Kishore Thota (kthota)
Title: Message How to convert bytea data type to character varying and vice versa   looking forward for ur assistance   kishore

Re: [SQL] SOLVED: Emulating 'connect by prior' using stored proc

2003-11-18 Thread Randolf Richardson, DevNet SysOp 29
[sNip] > In order to make this work with postgres an additional table is needed > that can hold the level (depth) of the branch because pgsql doesn't like > returning a tuple that isn't based on a defined structure. Once you've > created this table you can pretty much forget about it. > > CREATE T

Re: [SQL] HELP ME

2003-11-18 Thread Randolf Richardson, DevNet SysOp 29
> Where can i find a tutorial on PL/PGSQL?.Help me by > listing some sites to guide me in this context. Does the following meet your needs? Chapter 19. PL/pgSQL - SQL Procedural Language http://www.sql.org/sql-database/postgresql/manual/plpgsql.html -- Ra

Re: [SQL] Oracle 'connect by prior' now eaiser in 7.3?

2003-11-18 Thread Randolf Richardson, DevNet SysOp 29
[sNip] > See connectby() in contrib/tablefunc. Someone was working on SQL99 > recursive queries but it didn't get done for 7.4 -- perhaps it will be > in 7.5. In the meantime, connectby() is in 7.3 and might work for you. Oracle 8i doesn't seem to have any special indexing to handle this

Re: [SQL] Closed

2003-11-18 Thread Randolf Richardson, DevNet SysOp 29
> is here nobody? Is this group closed? I see that your question wasn't answered. There are people around here, but it looks like the activity is a bit scattered -- some newsgroups are much busier, such as Novell.Com's DeveloperNet and SpamCop.Net's help newsgroups, while there are oth

[SQL] strange DEFERRABLE behaviour

2003-11-18 Thread Tomek
Hi I've got some tables defined as: create table xx ( some_column references master_table It means this column is defined by default: NOT DEFERRABLE, INITIALLY IMMEDIATE I tried replacing rows in this table by new ones as: set autocommit=off; begin; set constraints all deferred; delete from

Re: [SQL] Expressional Indexes

2003-11-18 Thread Randolf Richardson, DevNet SysOp 29
[sNip] >> I have been considering using "calculated index" or "computed index" >> but dunno if that really conveys anything. > > Well, "Expression Indexes" is the most accurate. Or "Expression-Based > Indexes." What is the proposed definition of an "Expression Index?" When I se

[SQL] Arrays - a good idea?

2003-11-18 Thread Paul Ganainm
Hi all, Even though PostgreSQL supports arrays, is it a good idea to use them? I mean, they a) don't conform to the relational model and b) are not transportable so if one is designing an app, should one use them? When should they not/never be used? What are the criteria for justifying

Re: [SQL] Arrays - a good idea?

2003-11-18 Thread Yasir Malik
Hello, I don't think there's any reason you should use arrays. You can do everything using tables, and it probably would be easier to use tables instead. Extracting information from arrays is also more difficult if you're using something like JDBC or the connectivity available in PHP. I don't kn

[SQL] Need Help : Query problem

2003-11-18 Thread Abdul Wahab Dahalan
Hi Everybody! If I've a table like below kk | kj | pngk | vote ++--+-- 01 | 01 | a| 10 01 | 01 | b| 10 01 | 01 | c| 10 01 | 02 | a| 10 01 | 02 | b| 10 01 | 03 | a| 10 How do I write a query so that I can get a result as below [ select only a reco

Re: [SQL] SOLVED: Emulating 'connect by prior' using stored proc

2003-11-18 Thread Merrall, Graeme
> I have one question because I'm not clear about > something with your > implementation (a good one too by the looks of it -- thanks > for sharing > this information); if I start my query from an item at level > 5, will the > level be reflected as such, or will it dynamically start

Re: [SQL] Expressional Indexes

2003-11-18 Thread Greg Stark
"Randolf Richardson, DevNet SysOp 29" <[EMAIL PROTECTED]> writes: > For example, if I want to index on a date field but only have the index > keep track of the most recent 30 days (and then create a secondary index for > all dates) so as to improve performance on more heavily loaded syste