Does PostgreSQL take time to start streaming replication after restart master? I set streaming replication in postgresql 9.3. I have one master and 3 slaves and replication works fine. 

But when i restart the master server and login using postgres database, pg_stat_replication does not show replication details immediately. It takes several seconds ( around 5 seconds ) show replication details .

I want to know why this happens ? whether it's problem with pg_stat_replication ?

I want to make sure replication start as soon as server starts .
I want to make sure replication start as soon as server starts .


You can't. The server needs to start up, and it can only establish a streaming replication connection when it's up and ready.


  I want to know why this happens


Because there's no reason not to accept connections before streaming replication begins.

Among other things, if you're using WAL shipping instead of streaming replication, there might be no replication connection to wait for. Even if you're using streaming, you probably want the replica to keep on serving results if it loses its connection to the master.


  My thought was, when server started it will be ready to accept queries, and then after few seconds server start streaming replication. I though data will be lost in those few seconds.


It isn't.

The server is in recovery mode. Attempts to perform read/write queries will be rejected. This is the case whether or not there's a streaming replication connection.

After all, a server in hot standby mode that uses only a restore_command (no streaming replication) also rejects read/write queries.

You don't need to take any special action.

(In future, please try to include the background, the underlying problem, in your questions, so there's less guesswork and back and forth).