Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> "skomplikowane" zapytanie, Zbyt mała wydajność
sheldon
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 25.02.2004
Skąd: Brusy

Ostrzeżenie: (0%)
-----


Jak w temacie.
Mam problem z zapytaniem do bazy w mysql. Trwa ono nieskończenie długo (lub ~ 154sekundy).

  1. --
  2. -- Struktura tabeli dla `londoner_users`
  3. --
  4.  
  5. CREATE TABLE `londoner_users` (
  6. `user_id` int(5) NOT NULL AUTO_INCREMENT,
  7. `user_login` varchar(255) NOT NULL DEFAULT '',
  8. `user_pass` varchar(255) NOT NULL DEFAULT '',
  9. `user_name` varchar(255) NOT NULL DEFAULT '',
  10. `user_surname` varchar(255) NOT NULL DEFAULT '',
  11. `user_address` varchar(255) NOT NULL DEFAULT '',
  12. `user_city` varchar(255) NOT NULL DEFAULT '',
  13. `user_postcode` varchar(10) NOT NULL DEFAULT '',
  14. `user_province` int(5) NOT NULL DEFAULT '0',
  15. `user_gg` int(9) NOT NULL DEFAULT '0',
  16. `user_email` varchar(255) NOT NULL DEFAULT '',
  17. `user_email1` varchar(255) NOT NULL DEFAULT '',
  18. `user_phone` varchar(30) NOT NULL DEFAULT '',
  19. `user_cellphone` varchar(30) NOT NULL DEFAULT '',
  20. `user_fax` varchar(30) NOT NULL DEFAULT '',
  21. `user_certs` text NOT NULL,
  22. `user_info` text NOT NULL,
  23. `user_notices` text NOT NULL,
  24. `user_sworn` enum('yes','no') NOT NULL DEFAULT 'no',
  25. `user_busy` enum('yes','no') NOT NULL DEFAULT 'no',
  26. `user_paytype` int(5) NOT NULL DEFAULT '0',
  27. `user_date` int(15) NOT NULL DEFAULT '0',
  28. UNIQUE KEY `user_id` (`user_id`)
  29. ) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=1775 ;
  30.  
  31. -- --------------------------------------------------------
  32.  
  33. --
  34. -- Struktura tabeli dla `londoner_users_combinations`
  35. --
  36.  
  37. CREATE TABLE `londoner_users_combinations` (
  38. `user_combination_id` int(10) NOT NULL AUTO_INCREMENT,
  39. `user_id` int(5) NOT NULL DEFAULT '0',
  40. `combination_id` int(5) NOT NULL DEFAULT '0',
  41. `combination_prize` float NOT NULL DEFAULT '0',
  42. PRIMARY KEY (`user_combination_id`)
  43. ) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=12523 ;
  44.  
  45. -- --------------------------------------------------------
  46.  
  47. --
  48. -- Struktura tabeli dla `londoner_users_spheres`
  49. --
  50.  
  51. CREATE TABLE `londoner_users_spheres` (
  52. `user_sphere_id` int(5) NOT NULL AUTO_INCREMENT,
  53. `user_id` int(5) NOT NULL DEFAULT '0',
  54. `sphere_id` varchar(5) NOT NULL DEFAULT '',
  55. UNIQUE KEY `user_sphere_id` (`user_sphere_id`)
  56. ) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=91384 ;
  57.  
  58. -- --------------------------------------------------------
  59.  
  60. --
  61. -- Struktura tabeli dla `londoner_users_types`
  62. --
  63.  
  64. CREATE TABLE `londoner_users_types` (
  65. `user_type_id` int(5) NOT NULL AUTO_INCREMENT,
  66. `user_id` int(5) NOT NULL DEFAULT '0',
  67. `type_id` int(5) NOT NULL DEFAULT '0',
  68. `type_prize` float NOT NULL DEFAULT '0',
  69. UNIQUE KEY `user_type_id` (`user_type_id`)
  70. ) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=14104 ;


Są takie 4 tabele. Napisałem wyszukiwarkę, która pięknie działała na małej ilości użytkowników. Przy ponad 1700 - zaczyna się problem - zapytanie trwa zbyt długo, baardzo obciąża serwer.

Wygląda ono następująco:
(przykładowo)

  1. SELECT londoner_users.user_name AS name, londoner_users.user_surname AS surname, londoner_users.user_gg AS gg, londoner_users.user_phone AS phone, londoner_users.user_cellphone AS cellphone, londoner_users.user_email AS email, londoner_users.user_city AS city, londoner_users.user_postcode AS postcode, londoner_users.user_address AS address, londoner_provinces.province_name AS province, londoner_users.user_sworn AS sworn, londoner_users.user_id AS user_id
  2. FROM londoner_users_combinations LEFT JOIN londoner_users ON londoner_users.user_id = londoner_users_combinations.user_id
  3. LEFT JOIN londoner_users_spheres ON londoner_users_spheres.user_id = londoner_users.user_id
  4. LEFT JOIN londoner_users_types ON londoner_users_types.user_id = londoner_users.user_id
  5. LEFT JOIN londoner_provinces ON londoner_users.user_province = londoner_provinces.province_id
  6. WHERE londoner_users_spheres.sphere_id = '4' AND londoner_users_combinations.combination_id = '847' AND londoner_users.user_province = '15' AND londoner_users_types.type_id = '4'
  7. GROUP BY londoner_users.user_id


Problemem są ogromne tabele - londoner_users_spheres - ma ponad 68.600 rekordów oraz londoner_users_types - ponad 7000.

Może macie jakieś pomysły? :-(
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.12.2025 - 10:18