Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.www.php > #22770

Re: [OT] Info su BIGINT, INT, etc.

From Alessandro Pellizzari <shuriken@amiran.it>
Newsgroups it.comp.www.php
Subject Re: [OT] Info su BIGINT, INT, etc.
Date 2019-11-09 10:38 +0000
Message-ID <h2nj95F4c7oU1@mid.individual.net> (permalink)
References (3 earlier) <qphd11$lt5$1@gioia.aioe.org> <qphls1$1ub4$1@gioia.aioe.org> <qpjsqh$1mge$1@gioia.aioe.org> <h2b2q0Ffv79U1@mid.individual.net> <qpv4pf$hg8$1@gioia.aioe.org>

Show all headers | View raw


On 06/11/2019 18:52, ^Bart wrote:

>> Un suggerimento spassionato: ignora quel numero tra parentesi.
>>
> 
> Ah ok, quindi se si volesse sfruttare il valore massimo si potrebbe 
> omettere tale valore?

Non ho idea da dove arrivi quel valore tra parentesi. L'unica cosa che i
computer capiscono sono i bit. Un numero a 8 bit contiene 256 valori: da
0 a 255 se unsigned, da -128 a +127 se signed.

Tutto il resto è un tentativo di renderli user friendly. Fallito. :)

>> Guarda qui per sapere il numero massimo per ogni tipo intero:
>>
>> https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
> 
> Il valore 4294967295 per INT UNSIGNED è il numero massimo di record 
> (volgarmente righe) che posso inserire nella tabella mentre scrivere 
> INT(11) significa che ogni cella potrà ospitare al massimo un numero di 
> undici cifre?

Ignora il numero di cifre. Quello è per gli umani. Stai parlando a un
computer. Il numero di cifre per un INT UNSIGNED è 32 (bit).

Non è il numero massimo di record che puoi inserire. È il numero massimo
di identificatori univoci che puoi assegnare alle righe se usi INT
UNSIGNED per l'identificatore.

> A me interessa capire la logica per poi decidere se usare INT, BIGINT, 
> TINYINT, etc.

Devi usarlo come id? Allora fatti questa domanda.
Quante righe pensi di metterci (ora e in futuro)?
Meno di 4 miliardi? Usa INT UNSIGNED.
Più di 4 miliardi? Usa BIGINT UNSIGNED.

Non vale la pena usare gli altri tipi per un id (o AUTO INCREMENT, come
lo chiama MySQL), sia perché noi umani siamo pessimi a predire il
futuro, sia perchè dimensioni inferiori non portano nessun guadagno
prestazionale o di occupazione del disco significativi.

Bye.

Back to it.comp.www.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-10-26 14:28 +0200
  Re: [OT] Info su BIGINT, INT, etc. bramante <bramante@yopmail.com> - 2019-10-26 22:19 +0200
    Re: [OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-11-01 14:33 +0100
      Re: [OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-11-01 14:47 +0100
        Re: [OT] Info su BIGINT, INT, etc. bramante <bramante@yopmail.com> - 2019-11-01 17:18 +0100
          Re: [OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-11-02 13:29 +0100
            Re: [OT] Info su BIGINT, INT, etc. Alessandro Pellizzari <shuriken@amiran.it> - 2019-11-04 16:43 +0000
              Re: [OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-11-06 19:52 +0100
                Re: [OT] Info su BIGINT, INT, etc. Alessandro Pellizzari <shuriken@amiran.it> - 2019-11-09 10:38 +0000
  Re: [OT] Info su BIGINT, INT, etc. Leonardo Serni <lserni@gmail.com> - 2019-10-27 11:10 +0100
    Re: [OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-11-01 14:22 +0100
      Re: [OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-11-01 14:50 +0100
        Re: [OT] Info su BIGINT, INT, etc. Leonardo Serni <lserni@gmail.com> - 2019-11-04 00:02 +0100
          Re: [OT] Info su BIGINT, INT, etc. ^Bart <gabriele1NOSPAM@hotmail.com> - 2019-11-06 20:00 +0100
            Re: [OT] Info su BIGINT, INT, etc. Leonardo Serni <lserni@gmail.com> - 2019-11-08 15:56 +0100

csiph-web