DevProTalk

DevProTalk (http://www.devprotalk.com/index.php)
-   SQL baze podataka - Sponzor: Baze-Podataka.net (http://www.devprotalk.com/forumdisplay.php?f=10)
-   -   Najgori SQL query na svetu (http://www.devprotalk.com/showthread.php?t=4920)

bluesman 20. 03. 2008. 04:18

Najgori SQL query na svetu
 
Jos uvek ne mogu da poverujem u ovo sto sam video veceras. Mislim da covek koji napise ovakav query ne samo da treba da dobije otkaz nego jos i batine:

SELECT DISTINCT users.id, users.membership, (((acos(sin((35.7589*pi()/180)) * sin((users.latitude*pi()/180))+cos((35.7589*pi()/180)) * cos((users.latitude*pi()/180)) * cos(((-78.7798- users.longitude)*pi()/180))))*180/pi())*60*1.1515) as distance
FROM users
INNER JOIN laston ON users.id = laston.user_id INNER JOIN z_9 AS s9 ON users.id = s9.user_id INNER JOIN z_12 AS s12 ON users.id = s12.user_id INNER JOIN z_13 AS s13 ON users.id = s13.user_id INNER JOIN z_14 AS s14 ON users.id = s14.user_id INNER JOIN z_15 AS s15 ON users.id = s15.user_id INNER JOIN z_16 AS s16 ON users.id = s16.user_id INNER JOIN z_17 AS s17 ON users.id = s17.user_id INNER JOIN z_18 AS s18 ON users.id = s18.user_id INNER JOIN z_19 AS s19 ON users.id = s19.user_id INNER JOIN z_21 AS s21 ON users.id = s21.user_id INNER JOIN z_22 AS s22 ON users.id = s22.user_id INNER JOIN z_23 AS s23 ON users.id = s23.user_id INNER JOIN z_24 AS s24 ON users.id = s24.user_id INNER JOIN z_25 AS s25 ON users.id = s25.user_id INNER JOIN z_27 AS s27 ON users.id = s27.user_id INNER JOIN z_29 AS s29 ON users.id = s29.user_id INNER JOIN z_31 AS s31 ON users.id = s31.user_id INNER JOIN z_32 AS s32 ON users.id = s32.user_id INNER JOIN z_33 AS s33 ON users.id = s33.user_id INNER JOIN z_35 AS s35 ON users.id = s35.user_id INNER JOIN z_38 AS s38 ON users.id = s38.user_id INNER JOIN z_39 AS s39 ON users.id = s39.user_id INNER JOIN z_40 AS s40 ON users.id = s40.user_id INNER JOIN z_41 AS s41 ON users.id = s41.user_id INNER JOIN z_42 AS s42 ON users.id = s42.user_id INNER JOIN z_50 AS s50 ON users.id = s50.user_id INNER JOIN z_51 AS s51 ON users.id = s51.user_id INNER JOIN z_53 AS s53 ON users.id = s53.user_id INNER JOIN z_55 AS s55 ON users.id = s55.user_id INNER JOIN z_58 AS s58 ON users.id = s58.user_id INNER JOIN z_60 AS s60 ON users.id = s60.user_id
WHERE 1 AND users.gender = '4112' AND users.seeking = '4092' AND (s9.option_id = '137' OR s9.option_id = '138' OR s9.option_id = '139' OR s9.option_id = '140' OR s9.option_id = '141' OR s9.option_id = '142' OR s9.option_id = '433' OR s9.option_id = '434' OR s9.option_id = '481' OR s9.option_id = '482') AND (s12.option_id = '214' OR s12.option_id = '215' OR s12.option_id = '216' OR s12.option_id = '217' OR s12.option_id = '218' OR s12.option_id = '220') AND (s13.option_id = '221' OR s13.option_id = '222' OR s13.option_id = '223' OR s13.option_id = '224' OR s13.option_id = '225' OR s13.option_id = '226' OR s13.option_id = '227' OR s13.option_id = '429' OR s13.option_id = '435' OR s13.option_id = '495') AND (s14.option_id = '228' OR s14.option_id = '229' OR s14.option_id = '230' OR s14.option_id = '231' OR s14.option_id = '488' OR s14.option_id = '489' OR s14.option_id = '646') AND (s15.option_id = '232' OR s15.option_id = '233' OR s15.option_id = '234' OR s15.option_id = '645') AND (s16.option_id = '238' OR s16.option_id = '239' OR s16.option_id = '240') AND (s17.option_id = '242' OR s17.option_id = '243' OR s17.option_id = '244' OR s17.option_id = '245' OR s17.option_id = '246' OR s17.option_id = '436') AND (s18.option_id = '248' OR s18.option_id = '249' OR s18.option_id = '250' OR s18.option_id = '251' OR s18.option_id = '252' OR s18.option_id = '253' OR s18.option_id = '254' OR s18.option_id = '437') AND (s19.option_id = '256' OR s19.option_id = '257' OR s19.option_id = '258' OR s19.option_id = '259' OR s19.option_id = '260' OR s19.option_id = '261' OR s19.option_id = '262' OR s19.option_id = '263' OR s19.option_id = '264' OR s19.option_id = '265') AND (s21.option_id = '276' OR s21.option_id = '277' OR s21.option_id = '278' OR s21.option_id = '279' OR s21.option_id = '280' OR s21.option_id = '281' OR s21.option_id = '282' OR s21.option_id = '283') AND (s22.option_id = '285' OR s22.option_id = '286' OR s22.option_id = '287' OR s22.option_id = '288' OR s22.option_id = '492' OR s22.option_id = '493' OR s22.option_id = '494') AND (s23.option_id = '290' OR s23.option_id = '291' OR s23.option_id = '292' OR s23.option_id = '491' OR s23.option_id = '663') AND (s24.option_id = '294' OR s24.option_id = '295' OR s24.option_id = '296' OR s24.option_id = '297' OR s24.option_id = '298') AND (s25.option_id = '299' OR s25.option_id = '300' OR s25.option_id = '301' OR s25.option_id = '302' OR s25.option_id = '454' OR s25.option_id = '455') AND (s27.option_id = '312' OR s27.option_id = '313' OR s27.option_id = '314' OR s27.option_id = '315' OR s27.option_id = '316' OR s27.option_id = '317' OR s27.option_id = '318' OR s27.option_id = '319' OR s27.option_id = '320' OR s27.option_id = '344') AND (s29.option_id = '321' OR s29.option_id = '322' OR s29.option_id = '323' OR s29.option_id = '324' OR s29.option_id = '325' OR s29.option_id = '326' OR s29.option_id = '327' OR s29.option_id = '328' OR s29.option_id = '329' OR s29.option_id = '330') AND (s31.option_id = '333' OR s31.option_id = '334' OR s31.option_id = '335' OR s31.option_id = '336' OR s31.option_id = '337' OR s31.option_id = '338' OR s31.option_id = '339' OR s31.option_id = '341' OR s31.option_id = '342') AND (s32.option_id = '348' OR s32.option_id = '350' OR s32.option_id = '351' OR s32.option_id = '352' OR s32.option_id = '353' OR s32.option_id = '354' OR s32.option_id = '355' OR s32.option_id = '356' OR s32.option_id = '357' OR s32.option_id = '358') AND (s33.option_id = '362' OR s33.option_id = '363' OR s33.option_id = '364' OR s33.option_id = '365' OR s33.option_id = '366' OR s33.option_id = '367' OR s33.option_id = '368' OR s33.option_id = '369' OR s33.option_id = '370' OR s33.option_id = '371') AND (s35.option_id = '372' OR s35.option_id = '373' OR s35.option_id = '374' OR s35.option_id = '375' OR s35.option_id = '449' OR s35.option_id = '450' OR s35.option_id = '567' OR s35.option_id = '568' OR s35.option_id = '569' OR s35.option_id = '571') AND (s38.option_id = '376' OR s38.option_id = '377' OR s38.option_id = '378' OR s38.option_id = '379' OR s38.option_id = '380' OR s38.option_id = '381' OR s38.option_id = '382' OR s38.option_id = '383' OR s38.option_id = '384' OR s38.option_id = '385') AND (s39.option_id = '386' OR s39.option_id = '387' OR s39.option_id = '388' OR s39.option_id = '389' OR s39.option_id = '390' OR s39.option_id = '391' OR s39.option_id = '392' OR s39.option_id = '393' OR s39.option_id = '394' OR s39.option_id = '395') AND (s40.option_id = '402' OR s40.option_id = '403' OR s40.option_id = '404' OR s40.option_id = '405' OR s40.option_id = '406' OR s40.option_id = '407' OR s40.option_id = '408' OR s40.option_id = '409' OR s40.option_id = '410' OR s40.option_id = '411') AND (s41.option_id = '413' OR s41.option_id = '414' OR s41.option_id = '415' OR s41.option_id = '416' OR s41.option_id = '417' OR s41.option_id = '418' OR s41.option_id = '419') AND (s42.option_id = '421' OR s42.option_id = '422' OR s42.option_id = '423' OR s42.option_id = '424' OR s42.option_id = '425' OR s42.option_id = '426' OR s42.option_id = '427' OR s42.option_id = '453' OR s42.option_id = '641' OR s42.option_id = '643') AND (s50.option_id = '496' OR s50.option_id = '497' OR s50.option_id = '498' OR s50.option_id = '499' OR s50.option_id = '500' OR s50.option_id = '501' OR s50.option_id = '502' OR s50.option_id = '503' OR s50.option_id = '504' OR s50.option_id = '505') AND (s51.option_id = '509' OR s51.option_id = '510' OR s51.option_id = '511' OR s51.option_id = '512' OR s51.option_id = '513' OR s51.option_id = '514' OR s51.option_id = '515' OR s51.option_id = '516' OR s51.option_id = '517' OR s51.option_id = '518') AND (s53.option_id = '538' OR s53.option_id = '539' OR s53.option_id = '540' OR s53.option_id = '541' OR s53.option_id = '542' OR s53.option_id = '543' OR s53.option_id = '544' OR s53.option_id = '545' OR s53.option_id = '546' OR s53.option_id = '547') AND (s55.option_id = '4152' OR s55.option_id = '4162' OR s55.option_id = '4172' OR s55.option_id = '4182' OR s55.option_id = '4192' OR s55.option_id = '4202' OR s55.option_id = '4212' OR s55.option_id = '4222' OR s55.option_id = '4232' OR s55.option_id = '4242') AND (s58.option_id = '605' OR s58.option_id = '606' OR s58.option_id = '607' OR s58.option_id = '608' OR s58.option_id = '609' OR s58.option_id = '610' OR s58.option_id = '611' OR s58.option_id = '612' OR s58.option_id = '613' OR s58.option_id = '614') AND (s60.option_id = '682' OR s60.option_id = '683') AND users.approved = '1' AND users.deleted = '0' and users.main_photo_id !=0 AND (users.latitude > 35.3239421622 AND users.latitude < 36.1938578378) AND (users.longitude > -79.3142578966 AND users.longitude < -78.2453421034) AND users.dob > '1957-03-19' AND users.dob < '1988-03-19' AND users.id != '1' AND users.id NOT IN (SELECT blocked_user_id FROM blocked WHERE user_id = '1') AND users.id NOT IN (SELECT user_id FROM personal_definitions_attention) ORDER BY distance ASC LIMIT 500


Ovo sam dobio od coveka koji odrzava jedan server i koji kao i ja ne moze da se nacudi koji ludak moze ovo da napise. Hajde neko ako sme neka pusti ovaj query :)

bluesman 20. 03. 2008. 04:24

Da dodam da je ovo query koji se izvrsava na jako posecenom sajtu koji ima preko 6000 kverija u sekundi, i da dodam da su srbi autori ovog remek dela.

Evo sada kada gledam verovatno je to neki advanced search form pa trazi distance preko ZIP i longitude... + ima sliku, + nije obrisan + jos milion nekih stvari koje ni ne razumem... Ja bre kada imam vise od 3 JOIN-a po queriju - radim redesign baze, a ovo u zivotu nisam video... iskreno nisam ni znao da moze ovo :)

Sajt koristi 10 SQL servera i vlasnici ne mogu da se nacude kako hardware ne moze da pokrije zahtevnost :)

conica 20. 03. 2008. 04:36

evo ja cu da budem veoma iskrena, pa makar me nazvali neznalicom (:)): ja ovo ne bih UMELA da napisem
znaci totalno bih se zagubila kod treceg JOIN-a

edit: apropo, treba odati priznanje autoru..ovo je trebalo znati napisati

bluesman 20. 03. 2008. 04:45

To sam i ja rekao :)

Nego evo jos komentara administratora servera:

Citat:

inace, onaj kveri sam pustio na masteru pre vise od pola sata
i jos nije zavrsio
a master je ZVER
pazi, master ima 12 diskova u raid 10
16G rama
4 CPU-a
mislim, sta reci ;)
zver ;)
a ovo jos uvek traje ;)))
2600 sec i traje jos uvek
ne mogu vise da cekam, prekinucu ga :))))

Milos Vukotic 20. 03. 2008. 04:52

Off Topic: 'bem ti ovakvo radno vrijeme...

Pored svega ostalog, ovo je wtf samo za sebe:
users.gender = '4112'

Je li "gender" u smislu "pol"? Koliko ih moze biti? :)

conica 20. 03. 2008. 04:59

↑ LOL

Off Topic: a svaki put obecam sebi da cu leci pre 6

ppavlovic 20. 03. 2008. 05:26

Meni se dopada ono:

WHERE 1 AND users.gender = '4112'

P.S. Koji je kod generator koristio za ovako nesto ???

Mislim, kad sam pokusao da pravim jedan dating sajt, dosao samo do 5-6 joina ... i to se jaako sporo izvrsavalo. Pa sam onda zaboravio na normalizacije koje te uce u skoli. I sve je bilo kako treba. :)

twix 20. 03. 2008. 09:27

Cemu ovo sluzi a uz to i ne radi :1064: salim se, da li moze da se vidi sajt koji u pozadini mrsi ovaj sql ?

Aleksandar.Ilic 20. 03. 2008. 11:02

i jos ako nesto ovde nije indexirano :O

bofh 20. 03. 2008. 11:14

upit je u svakom slučaju skandalozan i lolkastičan.

ono što je meni skoro jednako skandalozno što se nigde ne primećuje opasno brkanje lončića.

sysadmin != dba != web developer

i da, btw, glupost je univerzalna stvar, tako da to nema veze sa srbima... ko se usprotivi tome proglasiću ga za izdajnilka lol


Vreme je GMT +2. Trenutno vreme je 00:55.

Powered by vBulletin® Verzija 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © DevProTalk. All Rights Reserved.

Mišljenja, saveti, izjave, ponude ili druge informacije ili sadržaji nastali na Sajtu su vlasništvo onoga ko ih je kreirao, a ne DevProTalk.com, tako da ne morate da se oslanjate na njih.
Autori poruka su jedini odgovorni za ovakve sadržaje. DevProTalk.com ne garantuje tačnost, kompletnost ili upotrebnu vrednost informacija, stavova, saveta ili datih izjava. Ne postoje uslovi pod kojima bi mi bili odgovorni za štetu ili gubitak koji je posledica bilo čijeg oslanjanja na nepouzdane informacije, ili bilo kakve informacije nastale kroz komunikaciju između registrovanih članova.
Web sajt može sadržavati linkove na druge web sajtove na Internetu ili neke druge sadržaje. Ne kontrolišemo niti podržavamo te druge web sajtove, niti smo pregledali bilo kakve sadržaje na takvim sajtovima. Mi nećemo biti odgovorni za legalnost, tačnost ili prikladnost bilo kog sadržaja, oglasa, proizvoda, usluga ili informacije lociranim na ili distribuiranih kroz druge web sajtove, niti za bilo kakvu štetu nastalu kao posledica takvih informacija. DevProTalk.com drži i čuva druga prava vlasništva na web sajtu. Web sajt sadrže materijale zaštićene copyright-om, zaštitne znakove i druge informacije o pravu vlasništva ili softver. Članovi mogu poslatu informacije zaštićene pravima vlasništva njihovih nosilaca i ona ostaju zaštićena bez obzira da li su oni koji prenose te informacije to naveli ili ne. Osim informacija koje su u javnom vlasništvu ili za koje dobijete dozvolu, nemate pravo da kopirate, modifikujete ili na bilo koji način menjate, objavljujete, prenosite, distribuirate, izvršavate, prikazujete ili prodajte bilo koju informaciju zaštićenu pravima vlasništva. Slanjem informacija ili sadržaja na bilo koji deo DevProTalk.com, Vi automatski dozvoljavate i predstavljate garanciju da imate pravo da dozvolite DevProTalk.com ili članovima DevProTalk.com bespovratnu, kontinualnu, neograničenu, globalnu dozvolu da koriste, kopiraju, izvršavaju, prikazuju i distribuiraju takve informacije i sadržaje i da iz takvih sadžaja koriste bilo koji deo u bilo koje svrhe, kao i pravo i dozvolu da koriste gore navedene sadržaje. Svi zaštitni znakovi (trademarks), logotipi, oznake usluga, firme ili imena proizvoda koji se pominju na ovom web sajtu su vlasništvo kojim raspolažu njihovi vlasnici.