Does the sword in Psalm 22 refer to the solder's spear that pierced Christ's side?

Does the reference to “the sword” in Psalm 22:20, find its fulfilment in John 19:34 where one of the soldiers with a spear pierced His side? and to what does the expression “dogs” refer?

The words referred to in the Psalm are, “Deliver my soul from the sword!” I cannot think that there is any reference here to the soldier’s spear! For one thing, the Lord did not pray to be delivered from the spear-thrust, for He was already dead, nor could He be said to be delivered from it, seeing it pierced Him, and was necessary for the fulfilment of the prophecy of Zechariah 12:10, “They shall look upon Me whom they have pierced.” No doubt, this was permitted for a secondary reason, as an ocular demonstration to all of the reality of His death in the outpouring of all His blood. The water coming out visibly after the blood would indicate that the fountain of that life-blood was entirely exhausted: “He poured out his soul unto death” (Isaiah 53:12). Then what could the sword be to which reference is made in verse zo, and from which the Lord prayed that His soul might be delivered? It was something terribly real, the pressure of which our Lord felt to His innermost soul. There was only one sword at Calvary, and that was the sword of which Zechariah spake----the sword of Jehovah—”Awake, 0 sword, against my shepherd, and against the man that is my fellow, saith the Lord of Hosts” (Zechariah 13:7). This was the sword of Eden that turned every way (Genesis 3: ), “the sore and great and strong sword” of Isaiah 27:1, with which “Leviathan, the piercing serpent” will one day be punished—the sword of divine justice meted out against sin, and with which the Holy Victim was smitten, “when He bore our sins in His own body on the tree,” and was treated as the sinner deserved.
As to the second part of the question, the expression “dog” refers, I think, to the Gentile element among those who crucified the Lord. It was they who administered the physical sufferings of the cross. “For dogs have compassed me, they pierced my hands and my feet”—clearly refers to the Roman soldiers, the crucifiers; and then follows v. 18: “They part my garments among them.” The moral sufferings of our Lord at the hand of Israel are depicted in vv. 6-8. But the sword of Jehovah surpassed them all, and it was being brought through that judgment unto the resurrection ground, which constituted the “deliverance from the sword” prayed for in Psalm 22:20.