Reputation: 433
i have a table with 2255440 records,
a cron job works every minute and inserts upto 50-100 records on every execution
inserts are working fine
the problem is that there is another cron job which is also running every minute.. this cron job updates these records according to the data recieved from other server
the problem is that the update query is taking around 6 - 7 seconds per update query
this is the table information and update query example
records are updated with this query
Query:
UPDATE `$month`
SET `acctstoptime`='$data->acctstoptime',
`acctsessiontime`='$data->acctsessiontime',
`acctinputoctets`='$data->acctinputoctets',
`acctoutputoctets`='$data->acctoutputoctets',
`acctterminatecause`='$data->acctterminatecause'
WHERE `radacctid`=$data->radacctid
Upvotes: 0
Views: 274
Reputation: 5588
CREATE INDEX:
Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.
Syntax:
CREATE INDEX [index name] ON [table name]([column name]);
Arguments
Name Description
index name Name of the index.
table name Name of the table.
column name Name of the column.
Example
Code:
CREATE INDEX radacctid ON table_name(radacctid);
Upvotes: 0
Reputation: 673
Is there a single-column index on column of 'radacctid'?
If not you should create one.
Upvotes: 1