hi friends
Well i am trying to create a query which uses a subquery in the from clause
I want as soon as the subquery fetches a row the , the subquery should stop executing , beacuse the table used by subquery has 40 million rows
THIS is so far i have been doing - SELECT column FROM some_table
-
WHERE EXISTS (SELECT * FROM some_other_table WHERE date BETWEEN start_date AND end_date)
if Any row Exists between start date and end date the main query should execute
But the table in subquery has 40 million rows so i need to stop the whole table scan , and exit the subquery as soon as any row comes from the subquery
I have tried usin IN, SOME, And ANY also
4 5380
Try adding 'LIMIT 1' at the end of the subquery.
Try adding 'LIMIT 1' at the end of the subquery.
WELL buddy milit is applied after the whole query is evaluated
If u have ever used a postgresql query emplain wizard in PGadmin
u will know that limit is applied after the whole query is evaluated
So limit wont work here
WELL buddy milit is applied after the whole query is evaluated
If u have ever used a postgresql query emplain wizard in PGadmin
u will know that limit is applied after the whole query is evaluated
So limit wont work here
For EXISTS, PostgreSQL documentation clearly says that
The subquery will generally only be executed far enough to determine whether at least one row is returned, not all the way to completion.
So even the LIMIT 1 should not be required. If there is no ORDER BY clause in a query there is no reason for all rows to be accessed.
If i do this
EXPLAIN
SELECT name FROM organisms WHERE EXISTS
(SELECT accession FROM features WHERE id ~ '^SAV' LIMIT 1);
I get
NOTICE: QUERY PLAN:
Result (cost=0.00..20. 00 rows=1000 width=32)
InitPlan -> Limit (cost=0.00..182 .71 rows=1 width=32)-> Seq Scan on features (cost=0.00..273 49.21 rows=150 width=32) -> Seq Scan on organisms (cost=0.00..20. 00 rows=1000 width=32)
I interpret it as the limit on the subquery being applied before the main query executes. I could be wrong.
For EXISTS, PostgreSQL documentation clearly says that
So even the LIMIT 1 should not be required. If there is no ORDER BY clause in a query there is no reason for all rows to be accessed.
If i do this
I get
I interpret it as the limit on the subquery being applied before the main query executes. I could be wrong.
YA I GOT IT, i read the manual again before ur message, and exists works as i expected, though i asked the qestion becuase of large execution time
Which was not because of the subquery in exists, there was some other mistake that i had been doing
But thanx for ur valuable TIME
regard Gaurav
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Guinness Mann |
last post by:
Pardon me if this is not the optimum newsgroup for this post, but it's
the only .NET newsgroup I read and I'm certain someone here can help me.
I have a C# program that checks for an error condition and if it finds
it it notifies the user with a MessageBox and then on the next line of
code (example in a minute) it calls Application.Exit().
To my astonishment, I stepped through the code with the debugger, and
watched it call...
|
by: Jon Bosker |
last post by:
I have written an application that lives in the systray but when I try
to close windows or logout it does not close my application and
therefore prevents windows from shutting down or logging me out. It is
essential that I solve this problem but I have run out of ideas can
anyone help (please!)
The application starts in Start.cs which kicks off the Systray form
using this call:
Application.Run(new Systray());
|
by: Bob Day |
last post by:
Using VS 2003, VB.net...
I am confused about the Application.Exit method, where the help states "This
method does not force the application to exit." Aside from the naming
confusion, how do I force the application to exit? See **** below for my
comments/questions in a simple example.
****In Sub Main, the Application.Exit works as expected, other sub main code
is ignored, and when the end sub is reached the application shuts down....
|
by: jdubey |
last post by:
hi
i have one asp.net application.from that application i am connecting to sql
sever on domain.earlier it was working properly.now i reinstalled sql server
and try to connect from asp.net.now it is giving error
sql server does not exit or access denied
Server is getting through query amalyzer.
i am not able to connect to server.
|
by: Per |
last post by:
Hi,
I have a problem that I can't figure out. I have a database application
to keep track of boxes that contain files. For data entry, I have a
form with a main form section for the box-specific data (box
description etc), and a subform for entering details on each file
that's in the box (type, subtype etc). The subform is in a datasheet
form, with one record on each row.
Some of the subform fields are filled in using drop-downs,...
| |
by: alexia.bee |
last post by:
Hi,
I my program runs other program(form) by process.start. In some cases
the other program gets exception and dies.
Can I get the reason of the termination of other program(Stopped by
user, exception). Note that when the other program dies due to
exception, it writes to messagebox.
does the "StandardOutput" and "StandardError" is only good for console
|
by: Roger Trask |
last post by:
Web Server: IIS6
PHP Version: 5.2.5
Database: MS SQLEXPRESS 2005
Loaded PDO Drivers: MSSQL, MySQL, ODBC
When executing the following script ($dbName, $username, $pw, $myDSN have been changed in this post to prevent access to my test environment):
<?php
try {
$dbname = "dbName";
|
by: Quill_Patricia |
last post by:
I have a Python script which is used to load data into a database. Up to
now this script has been run by customers from the Windows command
prompt using "python edg_loader.pyc". Any error messages generated are
written to a log file. A project team working in the same company as me
here would like to use this loading utility. They write UI applications
for Windows using Java. They were able to launch the Python script from
within Java by...
|
by: Tim Roberts |
last post by:
JRough <jlrough@yahoo.comwrote:
More than the syntax problems, you also have a logic problem here. How do
you think that "if" statement is ever going to be hit, given the statement
immediately before it?
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |