Is this wise?

Discussion in 'MySQL' started by abhilashdas, May 30, 2007.

  1. #1
    Is it ok to use a querry like this..

    SELECT sum(tbl_customerledger.pieces*tbl_purchase.price)'cost' FROM tbl_customerledger,tbl_purchase,tbl_customers where tbl_customerledger.code=tbl_purchase.code and tbl_customers.no=tbl_customerledger.customerno and tbl_customers.branch='$branchname' and tbl_customerledger.date>=$date

    My project uses this query and is working fine, but was wondering whether this could be a problem in long run because each of those tables could run up to a million entries or more easily.
    Can mysql handle this sort of queries, in tables with lot of data?
     
    abhilashdas, May 30, 2007 IP
  2. flippers.be

    flippers.be Peon

    Messages:
    432
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    should be ok work if you put correct indexes on the tables for the columns where you join on / filter on (don't forget to have an index that includes tbl_customerledger.date and tbl_customerledger.customerno as you filter on the date)

    as long as your query uses indexes and doesn't start table scans you don't have to worry..
     
    flippers.be, Jun 1, 2007 IP