Bonjour,

J'utilise:
Windows XP & Cygwin
perl, v5.10.0
MySQL 5.1.44
Toad for MySQL Beta 4.6.0.522

J'ai 3 tables:
bdd_operator: qui ne comporte que 2 colonnes de moins de 10 entrées
bdd_broadcaster: idem que la première
bdd_billing: c'est la table principale avec 8 colonnes et 1 million d'entrées, également des indexes et deux clés étrangères.

J'ai actuellement en indexe:
smartcard_id (colonne pouvant aller à des millions de référence différentes)
account_id (colonne pouvant aller à des millions de référence différentes)
billing_date (colonne la date en jour/mois/année/heure/minute/seconde)
product_id (colonne pouvant aller à des centaines de millier référence différentes)
broadcaster_id (colonne qui ne comporte qu'une vingtaine de référence unique)

Je voudrais savoir ce que vous pensez de ces indexes, s'il est judicieu ou pas d'en mettre sur la date etc...
Que dois-je corriger pour optimiser le temps de mes requêtes?


Ci-dessous un exemple de mes 3 tables:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Dumping structure for table bdd_report.bdd_operator
CREATE TABLE IF NOT EXISTS `bdd_operator` (
  `operator_id` int(4) unsigned NOT NULL,
  `operator_name` varchar(64) NOT NULL,
  PRIMARY KEY (`operator_id`),
  UNIQUE KEY `operator_id` (`operator_id`),
  KEY `operator_id_2` (`operator_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Liste des opérateurs';
 
# Dumping structure for table bdd_report.bdd_broadcaster
CREATE TABLE IF NOT EXISTS `bdd_broadcaster` (
  `broadcaster_id` char(8) NOT NULL,
  `broadcaster_name` varchar(64) NOT NULL,
  PRIMARY KEY (`broadcaster_id`),
  UNIQUE KEY `broadcaster_id` (`broadcaster_id`),
  KEY `broadcaster_id_2` (`broadcaster_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Liste des magasins';
 
# Dumping structure for table bdd_report.bdd_billing
CREATE TABLE IF NOT EXISTS `bdd_billing` (
  `smartcard_id` int(10) unsigned NOT NULL,
  `account_id` varchar(16) NOT NULL,
  `product_id` varchar(16) NOT NULL,
  `product_name` varchar(128) NOT NULL,
  `price` int(5) unsigned NOT NULL,
  `billing_date` datetime NOT NULL,
  `operator_id` int(4) unsigned NOT NULL,
  `broadcaster_id` varchar(8) NOT NULL,
  PRIMARY KEY (`smartcard_id`,`account_id`,`billing_date`,`product_id`,`broadcaster_id`),
  KEY `fk_opid` (`operator_id`),
  KEY `fk_brid` (`broadcaster_id`),
  KEY `account_id` (`account_id`,`product_id`,`billing_date`,`operator_id`,`broadcaster_id`,`smartcard_id`),
  CONSTRAINT `fk_brid` FOREIGN KEY (`broadcaster_id`) REFERENCES `bdd_broadcaster` (`broadcaster_id`),
  CONSTRAINT `fk_opid` FOREIGN KEY (`operator_id`) REFERENCES `bdd_operator` (`operator_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Liste des commandes';
 
INSERT INTO `bdd_broadcaster` (`broadcaster_id`, `broadcaster_name`) VALUES ('RIS', 'PARIS'), ('STB', 'STRASBOURG');
INSERT INTO `bdd_operator` (`operator_id`, `operator_name`) VALUES (3, 'FRANCE'), (12, 'ESPAGNE'), (15, 'ALLEMAGNE'), (16, 'BELGIQUE'), (17, 'LUXEMBOURG'), (460, 'SUISSE');
INSERT INTO bdd_billing VALUES("102652","1516135484","RIS4505001240","Le journal de 13h","499","20100223100115","16","RIS");
INSERT INTO bdd_billing VALUES("100768","4932156717","STBPdree15110","Espion(s)","752","20100228015556","3","STB");
Merci par avance pour votre aide.