473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Strange difference in query execution time

I have a view, vw_tc_user_acccess, for determing user access to certain
objects. On my machine, I get the following query execution times:

1. SELECT * FROM vw_tc_user_access: 33.04ms
2. SELECT * FROM vw_tc_user_access WHERE object_type = 'FORUM': 3.49ms
3. SELECT * FROM vw_tc_user_access WHERE object_type = 'CATEGORY': 107.53ms

Queries #2 and #3 are obviously a subset of #1, simply filtered by
object_type. My questions are:

1) How can #3 take 30 times as long as #2, given that in my databse they
have the exact same number of rows returned and are drawn from the exact
same tables?
2) How is it possible for #3, a subset of #1 with a very simple WHERE
clause, to take three times longer than #1 to execute?

The view definition is:

CREATE VIEW vw_tc_user_access AS
SELECT DISTINCT ur.user_id AS user_id,
arm.acl_action AS action,
ao.acl_object_type AS object_type,
ao.acl_object_key AS object_key
FROM tc_acl_role_map arm
INNER JOIN tc_acl_objects ao ON arm.acl_object_id = ao.acl_object_id
INNER JOIN tc_user_roles ur ON ur.role_id = arm.role_id;

I can provide table definitions if needed.

-j
--
Jeremy Jongsma
je****@jongsma.org
http://www.jongsma.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #1
1 1844
Jeremy Jongsma <je****@jongsma.org> writes:
My questions are: 1) How can #3 take 30 times as long as #2, given that in my databse they
have the exact same number of rows returned and are drawn from the exact
same tables?
2) How is it possible for #3, a subset of #1 with a very simple WHERE
clause, to take three times longer than #1 to execute? I can provide table definitions if needed.


What would be more useful is EXPLAIN ANALYZE output (and you have
ANALYZEd all the underlying tables, no?). This is a bit off topic
for pgsql-general though, please take it to pgsql-performance.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ryan | last post by:
Bit of an obscure one here, so please bear with me. I have two copies of a database which should be identical. Both have a complex view which is identical. I can open the views and the data is as...
4
by: Stefano | last post by:
Hi everibody, it's the first time i post on this newsgroup. I'm Stefano from Milano, italy. I'm a beginners with Sql2000. My problem is this. I run a View using enterprise manager and after less...
5
by: MGB | last post by:
I have a strange performance question hopefully someone can clarify for me. I take a production database and make a copy of it, called test, on the same instance on the same server both running at...
5
by: mas | last post by:
I have a Stored Procedure (SP) that creates the data required for a report that I show on a web page. The SP does all the work and just returns back a results set that I dump in an ASP.NET...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
6
by: Ryan | last post by:
I came across a situation that I've been unable to explain and was hoping somebody had an answer: I had written an update query which was taking about 8 seconds to run and considered it too...
23
by: Nishant Saini | last post by:
Dear All, We have a database which contains many tables which have millions of records. When We attach the database with MS SQL Server 2005 Standard Edition Server and run some queries (having...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
7
by: alexbf | last post by:
Hello, I have a stored procedure in SQL Server 2000. When I execute it through my .NET application (OleDbCommand), I can see (in SQL Profiler) that it takes 423 ms to complete. If I run the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.