[SQL] Querying Hierarchical Data

2003-03-03 Thread Eric
Hi, How do I access hierarchical data under PostgreSQL? Does it have SQL command similar to Oracle's CONNECT BY? Any help is appreciated Eric ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

[SQL] complex query

2003-03-03 Thread Matt Gerginski
I have two tables, users and options. The common element between the tables is "username". I want to select the "email" from "user" but only if the "mailing_list" option is set to true in the "options" table. Here are the tables: select username, email from users; username| e

Re: [SQL] HardCORE QUERY HELP!!!

2003-03-03 Thread Greg Stark
Metnetsky <[EMAIL PROTECTED]> writes: > It's for a class and my professor has a thing for brain teaser type > questions. Incidentally, TAs and Profs aren't stupid, and have been known to check on newsgroups and mailing lists for students asking for people to do their homework for them. -- greg

Re: [SQL] Forcing query to use an index

2003-03-03 Thread Michael Nachbaur
On Monday, Mar 3, 2003, at 15:32 US/Pacific, Josh Berkus wrote: Check out the thread: Re: [SQL] OUTER JOIN with filter in today's list; this relates to your problem. Then try your query as: I'll read through this, thank you. LEFT OUTER JOIN (SELECT * FROM Customer_Month_Summary WHRE CMS.Mon

Re: [SQL] Forcing query to use an index

2003-03-03 Thread Greg Stark
One suggestion I'll make about your data model -- I'm not sure it would actually help this query, but might help elsewhere: WHERE ( C.Disabled > '2003-02-28' OR C.Disabled IS NULL ) Don't use NULL values like this. Most databases don't index NULLs (Oracle) or even if they do, don't

Re: [SQL] Forcing query to use an index

2003-03-03 Thread Greg Stark
> -> Merge Join (cost=6106.42..6335.30 rows=2679 width=265) (actual time=859.77..948.06 rows=1 loops=1) Actually another problem, notice the big discrepancy between the estimated row and the actual rows. That's because you have the big OR clause so postgres figures there's

[SQL] SCHEMA's

2003-03-03 Thread Hepworth, Mike
Need some help with schema's. I want to be able make a user have a default schema other than public. I want to be able to have several schema's with the same group of tables define in each one. (Example) schema a (users 1,2,3) table a table b table c schema b (users 4,5,6

Re: [SQL] SCHEMA's

2003-03-03 Thread Tom Lane
"Hepworth, Mike" <[EMAIL PROTECTED]> writes: > I want to be able make a user have a default schema other than public. If the schema name is the same as the user name then this happens automatically. Otherwise, you want to set a search_path value for the user --- see ALTER USER and read up on the

Re: [SQL] Query Against a dblink View Takes Too Long to Return

2003-03-03 Thread Tom Lane
Dawn Hollingsworth <[EMAIL PROTECTED]> writes: > Nested Loop (cost=0.00..466.51 rows=1 width=24) (actual > time=226.39..1018072.99 rows=9353 loops=1) > -> Subquery Scan t1 (cost=0.00..0.01 rows=1 width=0) (actual > time=225.99..345.86 rows=9353 loops=1) > -> Result (cost=0.00..0.01