In the present paper, we investigate the optimal singularity at the origin for the functions belonging to the critical Sobolev space H n p , p ( R n ) , 1 < p < ∞ . With this purpose, we shall show the weighted Gagliardo–Nirenberg type inequality: (GN) ‖ u ‖ L q ( R n ; d x | x | s ) ⩽ C ( 1 n − s ) 1 q + 1 p ′ q 1 p ′ ‖ u ‖ L p ( R n ) ( n − s ) p n q ‖ ( − Δ ) n 2 p u ‖ L p ( R n ) 1 − ( n − s ) p n q , where C depends only on n and p. Here, 0 ⩽ s < n and p ˜ ⩽ q < ∞ with some p ˜ ∈ ( p , ∞ ) determined only by n and p. Additionally, in the case n ⩾ 2 and n n − 1 ⩽ p < ∞ , we can prove the growth orders for s as s ↑ n and for q as q → ∞ are both optimal. (GN) allows us to prove the Trudinger type estimate with the homogeneous weight. Furthermore, it is obvious that (GN) cannot hold with the weight | x | n itself. However, with a help of the logarithmic weight of the type ( log 1 | x | ) r | x | n at the origin, we cover this critical weight. Simultaneously, we shall give the minimal exponent r = q + p ′ p ′ so that the continuous embedding can hold.