Let $p(n)$ denote the smallest prime factor of $n$, and when $q$ is prime define the set
$$
R_q(x) = \{ q< n\le x\colon p(n) = q \}.
$$
The OP is then asking about the sum
$$
\sum_{\substack{n\le x \\ n\text{ composite}}} p(n) = \sum_{q\le x} q\cdot\#R_q(x).
$$
Note that the sum on the right-hand side can be restricted to $q\le\sqrt x$, as the OP pointed out.
Zander's answer to a similar question points out that $\#R_q(x) \le \frac xq$ and that therefore
$$
\sum_{q\le\sqrt x} q\cdot\#R_q(x) \le \sum_{q\le\sqrt x} x = x\pi(\sqrt x) \ll \frac{x^{3/2}}{\log x}.
$$
On the other hand, $R_q(x)$ includes all numbers of the form $qr$ where $r$ is prime and $q\le r\le \frac xq$, and so
\begin{align*}
\sum_{q\le\sqrt x} q\cdot\#R_q(x) &\ge \sum_{q\le\sqrt x} q \bigl( \pi(\tfrac xq) - \pi(q) \bigl).
\end{align*}
When $q\le\frac12\sqrt x$ we have $\tfrac xq \ge 4q$ and thus $\pi(\tfrac xq) \ge (4-o(1)) \pi(q)$; consequently,
\begin{align*}
\sum_{q\le\sqrt x} q\cdot\#R_q(x) &\gg \sum_{q\le\frac12\sqrt x} q \pi(\tfrac xq) \gg \sum_{q\le\frac12\sqrt x} q \frac{x/q}{\log(x/q)} \\
&\ge \frac x{\log x} \sum_{q\le\frac12\sqrt x} 1 = \frac x{\log x} \pi(\tfrac12\sqrt x) \gg \frac{x^{3/2}}{(\log x)^2}.
\end{align*}
I suspect this lower bound is the correct order of magnitude, since the lower bound of $\#R_q(x)$ is tight when $q>\sqrt[3]x$.