Re: [SQL] Query optimizing

2008-11-10 Thread Sebastian Ritter
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, Nov 10, 2008 at 8:43 AM, Sebastian Ritter [EMAIL PROTECTED] wrote: Hi all, I was hoping

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 the fact that it is a subquery

[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

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

[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

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 for

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
? In 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 two different tables: one table

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
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 sure which approach is considered correct. I have two

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 or services. Hmm. Are the services or clients

Re: [SQL] Database normalization

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

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

2007-08-28 Thread Sebastian Ritter
ON (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 The left outer join here would ensure