Results 1 to 10 of 10
  1. #1
    Lady_Jane is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2010
    Location
    Canada
    Posts
    49

    Question Query Not Responding

    Hi, I have a couple of queries that look something like this:


    Query1
    Code:
    SELECT a.SampleID, b.Taxa, a.Subtable
    FROM tblAll as a, tblAll as b;
    Query2
    Code:
    SELECT Query1.SampleID, Query1.Taxa, tblAll.Count, Query1.Subtable
    FROM tblAll RIGHT JOIN (Query1.SampleID = tblAll.SampleID) AND (tblAll.Taxa = Query1.Taxa);
    tblAll has around 39,000 records, and Query1 should result in about 500,000 records. Query1 has successfully run (i.e. shows up in datasheet view) but still takes ages (I haven't left it to complete) to produce or display all the rows. I have now converted Query2 to a make table query so that I won't have to run it over and over.

    It's been running for about 4 hours now and Access says it is not responding, but I think it's still going.

    I'm new to access and am trying to understand what it is that makes the query slow down so much. Is it simply because I am trying to create such a large number of records?
    Can you see any way to edit the above query(ies) to make anything run faster?

    It turns out that Queries 1 and 2 should result in roughly 1.9 million rows each. Is this way too many?
    Last edited by Lady_Jane; 11-08-2010 at 02:16 PM. Reason: additional information added

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    if tableAll has 39,000 records, Query1 will return 1,521,000,000 records.

    Query2 will return something SYNTAX ERROR. Please check the syntax of join and fix it.

    after fix, query2 will return 59,319,000,000,000 records.

    I think you are very new to Access, so may be you should tell us what you want to get from the table and then we can help.

  3. #3
    Lady_Jane is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2010
    Location
    Canada
    Posts
    49

    Smile

    I am certainly an Access "Novice"
    The queries posted actually came from another thread that you (I believe) helped me out with:
    https://www.accessforums.net/queries...tion-8264.html

    I have tblAll which has the following fields:
    SampleID, Taxa, Count, SubTable
    Composite primary key of SampleID and Taxa

    The end result ideally will be one table with SampleIDs as column header and taxa as row header, with the count of each taxon making up the table.
    There are, however, about 3000 samples. So the data are divided into subtables. I need to make sure that each subtable, has the same list of taxa, regardless of the count.

    (I suppose I could also have taxa as column headers and samples as rows, but I think there was a reason for my not having done that before.)

    I tried to use the same queries as the thread I posted above, but it is returning too many records.

    I hope this makes sense, thanks for your help.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you have 3000 samples, and did you mention there are at most 256 columns in a query? then you need 12 crosstab queris, is this what you want?

    Do you have any problem to follow the solution in the other thread?

  5. #5
    Lady_Jane is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2010
    Location
    Canada
    Posts
    49
    Yes, 12 crosstab queries is what I would like.

    The problem I am having is that in the previous thread, I first divided the data into 3 different tables, and then created 3 or 4 crosstab queries for each. This means that there were fewer taxa and fewer samples for each of the 3 tables.

    Now my task it to take all of the original data without dividing it into 3 tables, and perform the crosstab queries. When I run the first query from the previous thread in order to create a table in which every sample has every taxon I get a memory error.

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I forgot how I designed those queries. let me think about them.

    Would you please attach a sample database here?

  7. #7
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    The first query is very unefficient, maybe that cause the memory error. let me think about a better one.

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Please try this set of queries:

    Query: Makeup
    Code:
    select sampleID,Taxa,Ccount,SubTable from TblAll 
    UNION ALL 
    SELECT a.minOfsampleID, b.Taxa, Null , a.SubTable FROM 
        (select min(sampleID) as minOfsampleID,SubTable from tblAll group by subTable) AS a, 
        (select distinct Taxa from tblAll ) AS b
    CrossTab Query:
    Code:
    TRANSFORM Sum(MakeUp.Ccount) AS SumOfCcount
    SELECT MakeUp.Taxa
    FROM MakeUp
    WHERE (((MakeUp.SubTable)=1))
    GROUP BY MakeUp.Taxa
    PIVOT MakeUp.sampleID;

  9. #9
    Lady_Jane is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2010
    Location
    Canada
    Posts
    49
    Thanks!
    That looks to be working perfectly.

    Instead of creating a table where each sample contains every taxon, you are creating a table where each subtable contains every taxon, right?

  10. #10
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you are right.
    Before, I create every taxa for every sampleID, that makes a huge number of records.

    in the later one, I only create all taxa for one sample id in each subTable.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access Query Not Responding
    By sunharepal in forum Programming
    Replies: 4
    Last Post: 10-22-2010, 10:39 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums