
Mire donde mire todo me recuerda a ella... [?]
¡Añademe a tus favoritos!
Contacto
Post al azar
RSS
BUSCAR
Mapa de la web
Siempre me ha chocado un poquillo que no hubiera una pagina, o por lo menos que no haya una conocida, en la que tu describieras los sintomas que tienes y te dijera el problema médico más probable que tuvieras, en plan un listado de porcentajes de probabilidades de mayor a menor.
Naturalmente, tendria que estar acompañado por unas letras bien grandes y parpadeantes explicando que la web no tendria ninguna responsabilidad clinica y que fueras directo al medico, pero por lo demás no veo ninguna diferencia entre rebuscar en un listado enorme de enfermedades y una busqueda full-text (como las que se usan para encontrar la pagina web más adecuada para unas palabras dadas en los Googles y demás). Me parece, desde mi ignorancia, supongo, que dados un corpus de paginas web definidas por las palabras que contienen y otro de enfermedades relacionadas por un listado de sintomas (¡expresados con frases en lenguaje natural!) solo existe entre ambos una diferencia de semanticidad, no de algoritmica.
Imagino que el tema de la medicina se presta demasiado a demandas absurdas como para que merezca la pena meterse en un follón, pero es que ultimamente yo tambien tengo unos ciertos sintomas y no tengo ni idea de que me pasa. ¿Quizás de existir una web así, las personas en mi situacion, dados los resultados de la busqueda, nos animariamos a acercarnos a un medico de verdad? Quien sabe, pero en cualquier caso no me parece una mala idea para una web, desde luego a mi me vendria bien.
"Hello to everyone watching YouTube. We are U900. Please listen to 'Diamond Head.'"
Que no me entere yo que vais por la vida sin politono, maldita sea.
Si el tipo que lo dibujó tiene neurona y media, ya deberia estar vendiendo los posters a un doblón de a ocho, por lo menos.
Chingado chungamente de MundoGeek, que a su vez, supongo, lo vió en la web del autor, Cliff Chiang.
So yesterday night I found this interesting post talking about of the ages known alternative for getting a random row from a table of using two queries, the first for learning the number of rows, and the second to get just one row using the reserved SQL word offset and passing the number of rows as the top for a random funciont. In pseudo-SQL, something like this...
... instead of using our much hated but extremely common order by rand:
I've always thought the two querys alternative had to be slower even if it was just for the overhead of the two network accesses, but this guy proved me wrong by going all the hassle of testing it for real, and, really, the two querys approach resulted being an order faster in is tests than our "beloved" random ordering.
It was precisely these tests that sparkled my curiosity, because I don't feel like they where of my taste. First, he uses MySQL and Sqlite, what an strange combination. Sqlite is like the MsDOS of the databases, there are lots of better embedded ones if it was the reason. Second, what's the use of using MySQL and not telling what storage we are using for the tests? (Althought he hints in the commentaries it could be MyISAM, and asserts correctly that the row number is stored in the metadata of the table). And finally, the consists of just one query. Whoa, what an statistic.
So I did my own tests with my server, a MySQL 5.1.37-1ubuntu5 running on an Ubuntu 9.10, and they really show he's absolutely right:
In a table with a million rows, for getting a random row, using the two reads approach is an order of magnitude better than the naive random order way! MyISAM performing better than InnoDB was expected, but, sincerely, I believed the difference would be greater.
The data of the table is measured in milliseconds per query (Where do I write to get that measure unit named after me????) so obviously the lower the better, as is the time on average a query took to complete, calculated from the thousands of petitions the perl based clients did.
UPDATE: The querys, explained:
The naive approach, ordering by rand() and then getting the first row:
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | SIMPLE | bench_myisam | index | (NULL) | PRIMARY | 8 | (NULL) | 1000000 | Using index; Using temporary; Using filesort |
And the output for the two querys approach:
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | SIMPLE | (NULL) | (NULL) | (NULL) | (NULL) | (NULL) | (NULL) | (NULL) | Select tables optimized away |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | SIMPLE | bench_myisam | index | (NULL) | PRIMARY | 8 | (NULL) | 1000000 | Using index |
The tables are incredibly boring, just a million rows of an integer primary key and a varchar(200) of sample text. And here is the code for the Perl client I wrote to test the two querys approach. The other client is almost identical, but with just one query.
|
Can you please provide some actual data? Like the amount of rows in the table, and the table CREATE statements. Also if possible the query plans (EXPLAIN) |
|
The tables are a million rows big, and as simple as they could be, with an integer key called id and a varchar for the data. Anyway, I will update the post with as much data as possible as soon as possible. |
|
Right, I think you'll get a slightly different result with InnoDb, as the count() there sucks balls. |
|
Yep, that is what the graphic says, InnoDB reads using the count() use twice the time the MyISAM. I have not put the explain for the InnoDB count() because is a PITA for me to add formated code to the blog, but it says the InnoDB count() uses the index of the table to calculate the row count, while the MyISAM just gets it somewhere from the data engine. |
Aprovechando que ya casi nos hemos comido el jamón que me regaló mamá por estas felicisimas fechas, quiero compartir con vosotros una duda, una preocupación que arrastro ya bastantes meses, desde Madrid incluso.
La gran mayoria de las personas sensatas, es decir, todo el mundo menos Trolosil, ve bastante claro que tener cachorros humanos hembra en casa es bastante más problematico a largo plazo que tenerlos macho, por razones que en general diremos se refieren a la aparicion tempranera en exceso de una tercera generación, que mejor que sea en tejado ajeno.
Incluso algo se comenta de la posibilidad de la descendencia multiple univitelina, pero me he fijado que siempre se pasa de puntillas por un tema relacionado con los gemelos (no con los mellizos) (nunca he entendido como los guiris pueden vivir con una sola palabra para dos eventos tan dispares)... dicho tema, es naturalmente, el cambiazo.
¿Que pasa si estas bañando a Castor y Polux, te vas un momento a dispararle a alguien desde la ventana, y mientras apuntas por la telescopia, los crios se te intercambian? Es decir, los padres de gemelos les pintan una marca con rotulador no ya para distinguirles, sino simplemente para que no haya un cambio de posiciones en el cosmos?
Es que claro, que se te cambien Zoey y Kate de sitio en la bañera de chiquiticas, pues no pasa nada, las dos han triunfado absolutamente en lo suyo:

Pero, ay amigos, ¿que seguridad pueden tener los padres de Vicentin y Unai de que no los cambiaron en ningún momento? Vicentin es uno de los más grandes artistas de nuestro tiempo, y vive una vida de lujo extremo gracias a las exitosas peliculas que tiene en cartelera y sus discos de versiones de Chimo Bayo, es decir, todo un Tiger Woods de la vida, pero... ¿y el pobre gemelo al que llamamos Unai, que lo mas que ha conseguido en la vida fue capitanear al Lorca que casi sube a primera, y ahora vive en la miseria, sufriendo el dia a dia de entrenar a un equipo en no se que sitio con playa, y mucho me temo, teniendo que aguantar de vez en cuando al atontao de Morata, el aguileño renegado de Cadena Ser?
Solo por lo de tener que soportar a Morata me dan ganas de llorar por este pobre muchacho, condenado por un único error, el que cometió al cambiarse de lado en la cuna mientras sus padres no miraban. Muy triste.
|
Según se comenta el soportar a Morata debería incluir mirarle siempre de frente, lo contrario llevaría al bueno de Unai a pasarse de pie los partidos. Por lo demás, no he entendido una palabra |
|
Sólo tengo dos preguntas: 1)¿Quien es el de Muchachada Nui, Vicentín o Unai?. No me lo digas: en Albacete no ponen nombres raricos.... 2)¿Donde viven las gemelas de cualquiera de las dos zagalas de la afoto? Me conformo con una copia simple de cualesquiera Por lo demás yo tampoco he entendío mucho... |
|
El Ron del chino os tiene sorbio el coco: intento expresar mi paternal inquietud acerca de los cambiazos accidentales entre gemelos, que pueden llegar a tener tan trágicas consecuencias como el caso de estos dos muchachos univitelinos. |
|
Y para los despistados, las gemelas ni siquiera nacieron en el mismo continente. |
|
Vicentón no figura! El baile de la culebra sexy! Iré por recomendación de Saiyine y esposa (último comentario) |
|
Diole, hace años que no voy, incluso me ha costado un buen rato recordar donde era. (Los Toneles) |
|
En serio cuñao, te aburres mucho definitivamente. Me has dejado atónita con este post. Mientras que a los telediarios les da por poner a tias haciendo topless cuando no tienen nada que contar, (el que no me crea que vea el telediario en verano) a ti te da por escribir dudas existenciales un tanto absurdas. PD: No hay afán de ofender. |