473,395 Members | 1,689 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,395 software developers and data experts.

Selecting a filtered group result

3
hey

I'm trying to make a query which selects all rows that are not linked to the a certain number, i already managed to do this with a subquery, but this slows down the application, mainly caused because i have more then 100k rows.

Expand|Select|Wrap|Line Numbers
  1. (simplefied) table
  2. ############################
  3. # RowId # MessageId # Type #
  4. ############################
  5. # 1     # 104       # 3    #
  6. # 2     # 104       # 3    #
  7. # 3     # 104       # 4    #
  8. # 4     # 104       # 5    #
  9. # 5     # 104       # 4    #
  10. # 6     # 104       # 8    #
  11. # 7     # 105       # 3    #
  12. # 8     # 105       # 2    #
  13. # 9     # 105       # 1    #
  14. # 10    # 106       # 4    #
  15. # 11    # 106       # 3    #
  16. # 12    # 107       # 4    #
  17. # 13    # 107       # 6    #
  18. # 14    # 107       # 5    #
  19. # 15    # 107       # 9    #
  20. ############################
  21.  
so, a Message consists out of several types, now i want to select the messageId's that do not contain the type: 8,9 or 1. which is in this case message 106

is there any way to do this without a subquery?

Greetz Daanoz
Jan 17 '08 #1
4 1233
Delerna
1,134 Expert 1GB
Just a suggestion as I don't know the full details of your situation. It may or may not be possible for you

When I find that doing subqueries on large tables is too slow then I look to see
if I can bring a reduced number of records from the table into a table variable

I then perform the suquerying operation on the table variable instead.

Also you may have already done this so again, just suggesting, but do you have good indexes on the table.
Regards
Jan 17 '08 #2
daanoz
3
Just a suggestion as I don't know the full details of your situation. It may or may not be possible for you

When I find that doing subqueries on large tables is too slow then I look to see
if I can bring a reduced number of records from the table into a table variable

I then perform the suquerying operation on the table variable instead.

Also you may have already done this so again, just suggesting, but do you have good indexes on the table.
Regards
Sadly i'm not allowed to make any changes to the database, it's read-only because it's used by a bunch of other applications (not my choice ;))
Jan 17 '08 #3
daanoz
3
ok... solved by letting my PHP script set-up subresults, so the sub query doesn't have to be repeated time after time, but just once

Greetz Daanoz
Jan 17 '08 #4
ck9663
2,878 Expert 2GB
ok... solved by letting my PHP script set-up subresults, so the sub query doesn't have to be repeated time after time, but just once

Greetz Daanoz
the catch: you have to make sure your resultset is updated by the time it's accessed

-- CK
Jan 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Ben Gribaudo | last post by:
Hello! I am trying to query a MySQL table and retrieve either the earliest or the latest message in each thread. The messages are in a table with MsgID being the primary key and fThreadID...
13
by: Tony | last post by:
Hi everyone, I am new to javascript (and new to programming). I want to have to drop down menus. One will ask use to select from one of the 50 states. The second one will be ask user to select a...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
2
by: origin197511 | last post by:
Hello all... I'm having an issue with MSAccess 2000. I have a Form that holds records of my cartridge loads for a rifle and a subform that lists all groups that have been fired with that load. ...
6
by: aaj | last post by:
Hi all I use a data adapter to read numerous tables in to a dataset. The dataset holds tables which in turn holds full details of the records i.e. keys, extra colums etc.. In some cases I...
4
by: Tmuld | last post by:
Hello, I have a complete table within a dataset. I want a dataview to show particular filtered data - works great with the dv.rowfilter. But can I display only certain columns that are...
7
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I...
4
by: monomaniac21 | last post by:
hi! is it possible to do the aforementioned query - selecting only distinct in 1 col but retrieving all other cols at the same time. regards marc
2
by: Henrik Goldman | last post by:
Hi there, I'm new to sql and thus I'm having problems with a specific query which I hope you guys can help me with. Basicly I have a few tables which I'm trying to do a query on: Table...
1
by: Ralf | last post by:
Hi, i try to find a query for selecting one arbitrarily chosen row from each group of rows. Example: $ db2 "select * from T" A B C
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
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,...
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,...

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.