PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 28th, 2012, 02:49 PM
slarabee slarabee is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 3 slarabee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 24 sec
Reputation Power: 0
Query runs out of Memory

Hi I am running the following query:

SELECT
route_list_sb032206."Route_ID",
route_list_sb032206."StartDate",
route_list_sb032206."EndDate",
route_list_sb032206."Carrier_ID",
route_list_sb032206."SB_Carrier_Name",
route_list_032206."Date",
route_list_032206."Route_ID",
route_list_032206."Carrier_ID",
route_list_032206."Carrier_Name",
route_list_032206."Occupant_Addr",
route_list_032206."Occupant_City",
route_list_032206."State",
route_list_032206."Zip"
FROM

public."route_list_sb032206", public."route_list_032206"

Where route_list_sb032206."Route_ID" != route_list_032206."Route_ID"


and getting the following error:

out of memory for query result

********** Error **********


I know I am running this wrong so let me look to those smarter than I.

What I am trying to accomplish is that the Route_ID columns on both tables contain the same data but one table has 4 more IDs (rows) than the other column and 50 that are different (not in both) when I run an looking for matches - Inner Join (that query runs fine) . I am trying to get a result set of what those different route ID's are.

Any help would be most appreciated.

Sean

Reply With Quote
  #2  
Old December 10th, 2012, 06:01 PM
joeflinthiggins joeflinthiggins is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 14 joeflinthiggins User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 33 sec
Reputation Power: 0
Doing an inner join where something is not equal is a bad idea. This will return exponentially more matches than you're intending.

A better approach could be to do an inner join where they ARE equal, and then select a result set where the Route_ID is not in the inner join result set.

Example:

SELECT "Route_ID"
FROM public."route_list_sb032206"
WHERE "Route_ID" NOT IN
(SELECT route_list_sb032206."Route_ID",
FROM public."route_list_sb032206", public."route_list_032206"
Where route_list_sb032206."Route_ID" = route_list_032206."Route_ID") x1
UNION
SELECT "Route_ID"
FROM public."route_list_032206"
WHERE "Route_ID" NOT IN
(SELECT route_list_sb032206."Route_ID",
FROM public."route_list_sb032206", public."route_list_032206"
Where route_list_sb032206."Route_ID" = route_list_032206."Route_ID") x2;

This should return a set of Route_ID's that are only in one table or the other. All matches will be excluded due to the NOT IN.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Query runs out of Memory

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap