Jump to content


Photo

Insert/ Select help required


  • Please log in to reply
2 replies to this topic

#1 chrisdav

chrisdav
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 January 2003 - 04:47 PM

I have spent a long time trying to get this one - and I am now questioning my data structure

I have the following tables at present (telephone billing system)

TABLE -DATA
ID
ACCOUNT NUMBER
CALL TYPE
COUNTRY
CALL LENGTH
SEVERAL OTHER FIELDS NOT RELEVANT

TABLE - CUSTOMERS
ACCOUNT NUMBER
RATE TABLE

TABLE - RATETABLE
COUNTRY
PEAK
OFFPEAK
WEEKEND

On a row by row basis - I wish to update (or insert into a new table) the rate that I wish to charge for a call - taken from the DATA table.

e.g.
row 1 DATA contains the following information
ID = 1
ACCOUNT NUMBER = ABC123
CALL TYPE = PEAK
COUNTRY CODE = 44

I then get the rate table to be used from customers, and use it to select the correct rate \'where ratetable.country = data.country and ratetable.call type = data.call type\'

Have managed to do this in php - takes a very long time tho\' as it is running the script on a WHILE loop and there is approx 500k rows in data.

It strikes me there must be a more direct way of doing this - if not I will go back and have a look at my php code.

Any thoughts gratefully received - if my data structure (or explanation) could be improved then I will do.

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 31 January 2003 - 06:51 PM

To do that

You have to give a look on indexes

Check your mysql help and get the syntax to create indexes

Once you do that that will improve the perfomance.

Hope this gives u some Idea :idea:
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 chrisdav

chrisdav
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 February 2003 - 12:14 PM

Thanks for that - presume you mean that my php will work faster if I create indexes on my fields.

I will give that a go and see what happens




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users