You should know that to engage in optional knowledge is superior to engaging in optional acts of worship. This is the unanimous opinion of the four Imams and other leading personalities of Islam. Ibn ‘Abbas, may Allah be pleased with him, said: “To discuss matters concerning knowledge for a little while is better than engaging in worship for the entire night.” 
Ar-Rabi’ ibn Sulayman al-Muradi, a student of Imam Shafi’i, may Allah have mercy on him, said: “I heard ash-Shafi’i saying: ‘Seeking knowledge is superior to optional Salah.'” 
Imam al-Kashmiri, may Allah have mercy on him, said: “Do not refute the superiority of knowledge because Malik and Abu Hanifa, may Allah have mercy upon them both, are of the opinion that occupying oneself with knowledge is better than occupying oneself with optional prayers. There are two narrations from Ahmad, may Allah have mercy on him, with regards to this: (1) That knowledge is superior. (2) That Jihad is superior. As mentioned by Ibn Taymiyyah, may Allah have mercy on him, in Minhaj as-Sunnah‘” 
Imam Ahmad, may Allah have mercy on him, leaves his optional prayers in order to engage in discussions with Abu Zur’ah, may Allah have mercy on him.
Imam Abu Zur’ah ar-Razi was one of the Imams of Hadith and a contemporary of Imam Ahmed. ‘Abdullah, the son of Imam Ahmed, narrates:” When Abu Zur’ah came to Baghdad, he stayed with my father. He used to engage in a lot of discussions with my father. One day, I heard my father saying: ‘Today I only offered the fard salah [the compulsory prayers and not the optional prayers]. I gave preference to sitting and discussing with Abu Zur’ah over any optional Salahs.'” 
 : Adh-Dhahabi: Tadhkirah al-Huffaz.
 : Ibn ‘Abd al-Barr: al-Intiqa’.
 : Kashmiri: Fayd al-Bari ‘ala Sahih al-Bukhari.
 : Ibn Abi Ya’la: Tabaqatal-Hanabilah.
(The Sunnah way of the Sufis, Imam Abu Harith al-Muhasibi, researched and explained by Shaykh ‘Abd al-Fattah Abu Ghudda)