Re: [SQL] Query optimizing

2008-11-10 Thread Sebastian Ritter
Cheers for you help guys. Having filtered and then joined has substantially reduced the run time. Much obliged, Sebastian On Mon, Nov 10, 2008 at 12:32 PM, Richard Huxton <[EMAIL PROTECTED]> wrote: > Sebastian Ritter wrote: > > Could it have something > > to do with

Re: [SQL] Query optimizing

2008-11-10 Thread Sebastian Ritter
Cheers for this Richard. The more I think about it, I believe the join is being made against ALL issues and followups first and then filtered by my where clause conditions afterwards. This would in incur a scan against all 15,000 issues and 95,000 followups. Set theory tells me that I should not us

Re: [SQL] Query optimizing

2008-11-10 Thread Sebastian Ritter
in the INNER query a > bit more if you use a restriction clause like "WHERE n_issue = i.id" in > that. It will certainly lower the number of rows returned by it to only 1 > result. > > Regards > > -- > Helio Campos Mello de Andrade > > > > On Mon

[SQL] Query optimizing

2008-11-10 Thread Sebastian Ritter
Hi all, I was hoping to receive some advise on a slow running query in our business' Issue Tracking System. To shed some light on the below mentioned queries, here is a brief summary of how users interact with the system. The two main components in the system are a Issues and Followups. An Issue i

[SQL] PL/pgSQL question

2008-02-14 Thread Sebastian Ritter
Hi all, I have a question regarding functions. How can I return zero rows from a function whose return type is a table row? I did the following test and it did not work as expected: CREATE OR REPLACE FUNCTION fn_get_user (integer) RETURNS usertable AS ' DECLARE in_userid A

Re: [SQL] Was: fetch first rows of grouped data

2007-08-28 Thread Sebastian Ritter
(cities.id = x.city_id) I think that would work. Seb On 8/28/07, Sebastian Ritter <[EMAIL PROTECTED]> wrote: > > Hi There, > > You can do something like : > > SELECT * FROM cities c LEFT OUTER JOIN events e ON (c.id =e.city_id) ORDER > BY e.date DESC LIMIT 2 > &g

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Thanks guys, Sebastian On 8/28/07, Bart Degryse <[EMAIL PROTECTED]> wrote: > > Im using Django as my Object relational Mapper so im pretty sure I > can not add a constraint such as ... > Then you should seriously consider changing your mapper. > > >>> "Seba

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Hi, On 8/28/07, Andrew Sullivan <[EMAIL PROTECTED]> wrote: > > On Tue, Aug 28, 2007 at 03:37:22PM +0100, Sebastian Ritter wrote: > > Thanks for the information. > > > > Both tables would be exactly sames apart from the foreign key relation > to > > clients

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
be overlap between client_ids and service_ids. Cheers, Sebastian On 8/28/07, Erik Jones <[EMAIL PROTECTED]> wrote: > > On Aug 28, 2007, at 6:47 AM, Sebastian Ritter wrote: > > > Hello, > > > > I have a fairly basic question about database design where im not &g

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
terms of searching speed that is. Kindest regards. Sebastian On 8/28/07, Andrew Sullivan <[EMAIL PROTECTED]> wrote: > > On Tue, Aug 28, 2007 at 12:47:45PM +0100, Sebastian Ritter wrote: > > > The update/message format is exactly the same for both. Should I make > tw

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Hello, > > I have a fairly basic question about database design where im not sure > which approach is considered correct. > > I have two different entities: Clients and Services. Both allow users to > add progressive updates about the two entities. > > The update/message format is exactly the same