I have table in SQL-Server with 10 columns, one of is IP varchar(39). I store IP addresses here and this field has secondary non-clustered index because I perform search by this field.
The field set to 39 symbols and it is more than enough for IPv4. Will I gain performance benefit if I will set this field to exact IPv4 address size 15 symbols?
The performance benefit is there but very small to take into account. But, if you data is of fixed length you should go with CHAR/NCHAR for it, as wasting storage space for some fixed data is not recommended.
Also, if by mistake you try to enter a bigger value for IPV4 address, you will not be able to do the same.