Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: SQL pour trouver le premier libre?



Magnifique.
Merci beaucoup.
Maintenant, je vais essayer de comprendre comment ça marche....

Merci, bon WE

PC

Jean-Paul Argudo a écrit :
Re (dernier post, promis)

Mieux, non :-)

Non c'est mieux *après* le café...


test2=> select a+1 as id_disponible from nombres except select a from
nombres order by id_disponible limit 1;

 id_disponible
---------------
             4
(1 ligne)


C'est à dire que la condition WHERE ne sert plus à grand chose (dans la
mesure où a>0 tout le temps) dans mon exemple !


test2=> explain select a+1 as id_disponible from nombres except select a
from nombres order by id_disponible limit 1;
                                        QUERY PLAN

------------------------------------------------------------------------------------------
 Limit  (cost=333.73..333.78 rows=1 width=4)
   ->  SetOp Except  (cost=333.73..353.13 rows=388 width=4)
         ->  Sort  (cost=333.73..343.43 rows=3880 width=4)
               Sort Key: id_disponible
               ->  Append  (cost=0.00..102.45 rows=3880 width=4)
                     ->  Subquery Scan "*SELECT* 1"  (cost=0.00..53.65
rows=1940 width=4)
                           ->  Seq Scan on nombres  (cost=0.00..34.25
rows=1940 width=4)
                     ->  Subquery Scan "*SELECT* 2"  (cost=0.00..48.80
rows=1940 width=4)
                           ->  Seq Scan on nombres  (cost=0.00..29.40
rows=1940 width=4)
(9 lignes)





---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
       message can get through to the mailing list cleanly





Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group